Datatable field value?

UI Components for Vue
Post Reply
stajne
Posts: 1
Joined: 11 Jul 2014, 16:51

29 Jun 2020, 16:06

I have DataTable that iterates over an array of currentOrders (which have a field delay in them). I have a column that i want to change css depending on value (if delay > 0 "color : red" if delay < 0 "color : green") and thought about doing that with ternary operator but the thing is i don't know how to get the value to compare it with 0.

Code: Select all

      <DataTable
        :value="currentOrders"
        :paginator="true"
        :rows="20"
        :row-hover="true"
        :selection.sync="selectedOrders"
        :resizableColumns="true"
        columnResizeMode="expand"
        sortField="deliveryTimeString"
        :sortOrder="-1"
      >
      
      <Column
          headerStyle="width: 5em"
          field="delay"
          header="Delay"
          key="delay"
          :sortable="true"
        ></Column>
        
        </DataTable>

I wanted to put something like

Code: Select all

      <Column
          headerStyle="width: 5em"
          field="delay"
          header="Delay"
          key="delay"
          :sortable="true"
          :bodyStyle="DELAY_VALUE> 0 ? 'color:red' : 'color:green'"
        ></Column>

but i can't get anything in place of DELAY_VALUE to work. Can anyone help me?

vanna
Posts: 2
Joined: 29 Jun 2020, 23:05

01 Jul 2020, 15:34

Column is for whole column. You might want to specify style on cell level.


Post Reply

Return to “PrimeVue”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 6 guests