Author Topic: class/style of row based on row data  (Read 5528 times)

webifi

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 45
    • View Profile
class/style of row based on row data
« on: February 05, 2015, 08:10:05 pm »
There doesn't appear to be a rowInit event.

Id like an easy way to set the class/style of a row without having to re-iterate the grid rows after they are rendered, or without injecting data into the data array before rendering the grid.

Does something like this exist?

rowInit: function(ui){
    var $tr = ui.$tr, rowData = ui.rowData;
    if(rowData.days_past_due >= rowData.terms){
        $tr.addClass('past-due');
    }
}

Or, something like this?

rowModel: {
    init: function(ui){
    }
    cls: function(rowData,rowIndx){
        return rowData.my_index>0?'my-class':null;
    }
    style: function(rowData,rowIndx){
        return rowData.my_index>0?'background-color:red':null;
    }
}
« Last Edit: February 05, 2015, 08:49:14 pm by webifi »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6260
    • View Profile
Re: class/style of row based on row data
« Reply #1 on: February 06, 2015, 01:02:46 am »
Thanks for nice suggestion, consider it ( or some kind of its variant ) done in one of the next versions.

Currently the optimum way to change class/style/data of row /cell based on row data/ any other condition is to do it in JSON data itself while loading data into the grid.

If the row data/ condition changes during runtime e.g., by editing or copy/paste then listening to change event is required.

webifi

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: class/style of row based on row data
« Reply #2 on: April 08, 2015, 09:40:03 pm »
Has this functionality been added?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6260
    • View Profile
Re: class/style of row based on row data
« Reply #3 on: April 08, 2015, 10:03:54 pm »
rowInit or its variant would be added for convenience in next version.

However if you face any problem in adding row class/style based on row data with current API, please let's know.

webifi

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: class/style of row based on row data
« Reply #4 on: April 08, 2015, 10:18:21 pm »
Roughly how long until a version will be out with this?  The current method of either injecting data into JSON  or iterating and adding classes to the rows after rendering is not ideal.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6260
    • View Profile
Re: class/style of row based on row data
« Reply #5 on: April 08, 2015, 11:17:45 pm »
ETA is by end of the current month.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6260
    • View Profile
Re: class/style of row based on row data
« Reply #6 on: July 09, 2015, 06:12:45 pm »
It's been added in v3.0.0