No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Multi conditional q-table row formatting.

    Help
    2
    4
    917
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      atpim last edited by atpim

      I want to format q-table using multiconditions for rows:

      <q-table
          :title="'Exposure Data for Loan ID: ' + selectedID + ' [' + valuationCurrency + ']'"
          :data="TableData"
          :columns="TableCols"
          row-key="Name"
          hide-bottom
          class="col-9 valuation-exposure-table"
          style="margin: 0 auto;"
          :pagination.sync="pagination"
        >
          <template v-slot:body="props">
            <q-tr :props="props" :class="tableFormat">
              <q-td v-for="col in props.cols" :key="col.name" :props="props">{{ col.value }}</q-td>
            </q-tr>
          </template>
        </q-table>
      

      However when I assign tableFormat class I get error:
      TypeError: Cannot read property 'row' of undefined

      So here is my computed class with my multiple conditions

      tableFormat() {
            if (
              this.props.row.Name === "Scheduled CF to equity before costs" ||
              this.props.row.Name ===
                "Scheduled CF to equity after servicing and funding" ||
              this.props.row.Name === "Expected CF to equity" ||
              this.props.row.Name === "Present value equity"
            ) {
              return "text-bold";
            } else if (
              this.props.row.Name === "Inputs used" ||
              this.props.row.Name === "Outstanding balance" ||
              this.props.row.Name === "Cash flows payments"
            ) {
              return "bg-accent text-white text-subtitle2";
            } else {
              return "bg-white text-black";
            }
          },
      
      1 Reply Last reply Reply Quote 0
      • s.molinari
        s.molinari last edited by

        1. Don’t use text like that as your row name. It’s not robust.
        2. You need to pass your props into your computed.

        Scott

        A 1 Reply Last reply Reply Quote 0
        • A
          atpim @s.molinari last edited by

          @s-molinari
          How should I pass it to props?

          1 Reply Last reply Reply Quote 0
          • s.molinari
            s.molinari last edited by

            Try :class="tableFormat(props)"

            Scott

            1 Reply Last reply Reply Quote 0
            • First post
              Last post