tonytomov/jqGrid — pull request #284 by OlegKi (2012-03-26 11:36:45+00:00)
Title: Implementation of rowattr callback

(copy of [the previous pull request](https://github.com/tonytomov/jqGrid/pull/276))

Hello Tony,

I posted some time before [the suggestion](http://www.trirand.com/blog/?page_id=393/feature-request/introduce-rowattr-jqgrid-like-cellattr-but-for-setting-attributes-on-tr-element-instead-of-td/#p25555) to implement `rowattr` callback with the functionality close to `cellattr`. The pool request contains the implementation of the suggestion.

In main difference to `cellattr` is the format of return value which should be an **object** and not a **string**, so be implemented like in the example

rowattr: function (rowData, inputRowData) {
return rowData.closed ? {class: "myRowClass"} : {};
}

or

rowattr: function (rowData, inputRowData) {
return rowData.closed ? {style: "background:yellow"} : {};
}

It simplifys the analyzing. The usage of it in the form `' class="mystyle"'` should be parsed more carefully (`celp.indexOf('style') > -1`, but we have no `style` attribute inside).

[The demo](http://www.ok-soft-gmbh.com/jqGrid/AbhishekSimon10-rowattr-.htm) uses XML and [another](http://www.ok-soft-gmbh.com/jqGrid/ChangeFiledNameInSearchingDialog-rowattr-.htm) uses JSON as input. The demos use modified version of `grid.base.js`.

The first parameter of `rowattr` callback - `rowData` parameter has "named format" (object with the properties like in `name` from items of `colModel`). The format is the same for XML and JSON and it's not depend from `jsonReader` or `xmlReader` settings. The second parameter `inputRowData` is the row exactly like it be in the input data.

Additional advantage is that one have now `rd` variable which can be used as additional parameter of `addCell` which will be forwarded to `formatter`. So one could add later one more parameter to custom formatter to have the same format of input data in case of first loading of data and the call of the next time (in case of `loadonce: true` option).

Best regards
Oleg

Signed-off-by: Dr. Oleg Kiriljuk