0

I found that it's not possible to change data on other pages by using setRowData, and I found that the only way is using a getGridParam -> change data -> setGridParam(newdata).

So question, is it possible to setGridData(myData) with css styles ONLY FOR THE CELL?

I've tried to do setCell({ some css }) when i do paging, but it removes these css styles.

Previous code:

 onPaging: function() {
                var rows = self.jqgridHTML.getRowData();
                var rowNum = rows.length;
                var collection = self.model.get('collection');
                console.log(rowNum);
                for (var i = 0; i < rowNum; i++) {
                    var alarmData = rows[i];
                    //var alarm = collection.get(alarmData['name']);
                    var alarm = self.lookuptable[alarmData['name']];
                    var color = alarm['alarm'].attributes['color'];
                    self.jqgridHTML.jqGrid('setCell', i + 1, 3, '', {
                        'background-color': color
                    });
                }

                console.log('page changed');
            }

Thanks in advance!

  • It's do possible to use `setRowData`. I suppose that you have some problems because of wrong usage or becuase of wrong place in your code where you try to use `setRowData`. The code which you included in your question have also problems. You try to change cell style inside of `onPaging` callback, but the callback will be called **before changing the page**. Moreover you use very suspected `id` values `i + 1`. If you make some changes inside of `onPaging` then you change **old page**, but the page will be immediately changed and the changes will be disappeared. What scenario you have? – Oleg Jun 26 '14 at 06:59
  • @Oleg, I just want to set fixed css style to some cells. And I dont wanna them to disappear after the changing of page. Scenario: 1) Download data for each row. 2) Do css for this portion of data. 3) If alarm status is changed, change css. – Aleksander Korovin Jun 29 '14 at 16:24
  • You misunderstood how the grid will be filled. You can set CSS on every cell of the column by usage `cellattr` callback in `colModel`. You can set CSS on rows by usage of `rowattr` callback. Both will be called **during filling the grid**. On paging the grid body will be removed and rebuild one more time. So If you make any changes on grid inside of `onPaging` the cells will be removed immediately after the call of `onPaging` callback. – Oleg Jun 29 '14 at 18:53
  • [The answer](http://stackoverflow.com/a/10531680/315935) demonstrates how to use `rowattr` callback. [Another answer](http://stackoverflow.com/a/6048865/315935) shows how to use `cellattr`. – Oleg Jun 29 '14 at 18:58

0 Answers0