|
Title: Highlighting particular columns in the datagrid [Solved] Post by: Darrel on March 26, 2016, 02:38:02 PM Hello,
I have a scenario where I wish to highlight some particular columns in the datagrid. This is based on the values from the column present above the current row. If the value in the previous row's column does not match with the value in the current row's column for that particular column, then the data should be highlighted in some colored font/background. This is my basic fiddle link, without the highlighting code: http://jsfiddle.net/DROCKS/hLdrwmkc/1/ (http://jsfiddle.net/DROCKS/hLdrwmkc/1/) From the fiddle data, I want to highlight "price2" in the second row since it differs from the value above it which is "price1"; highlight "price1" in the third row since it differs from the value above it which is "price2" and in the final row, i.e, the fourth row, highlight "data1" and "name2" since their values differ from the above respective column values... I did happen to read about rowStyler and styler in documents section, but noticed that this has to be maintained in the during the datagrid column creating part only. In my case, there maybe a styler on some particular row's column or there may be no styler at all if the data does not differ. I tried to do the same by referring the details given in the following post but I get an error: http://www.jeasyui.com/forum/index.php?topic=5268.0 (http://www.jeasyui.com/forum/index.php?topic=5268.0) and it's respective fiddle: http://jsfiddle.net/jg0t94g7/56/ (http://jsfiddle.net/jg0t94g7/56/) This is my fiddle link after trying the styler property: http://jsfiddle.net/DROCKS/hLdrwmkc/2/ (http://jsfiddle.net/DROCKS/hLdrwmkc/2/) So I was confused, how to achieve the same. Please could anyone help me out with this. Any help would be appreciated. Thanks in advance!!! Title: Re: Highlighting particular columns in the datagrid Post by: stworthy on March 26, 2016, 08:52:33 PM The 'highlight' function can be defined as:
Code: function highlight(val,row,lol){This is the updated fiddle link: http://jsfiddle.net/hLdrwmkc/3/ Title: Re: Highlighting particular columns in the datagrid Post by: Darrel on March 27, 2016, 11:21:24 PM Hello stworthy,
Thanks for your response. It does work as expected but however I'm facing one more problem in this scenario. My column data comes as a JSON object having the key and value pairs enclosed within double quotes. The following is my code snippet for achieving: Code: $(function(){The above code throws an error an only renders/creates the column headers. The similar code is simplified and added in the fiddle link as follows: [link]http://jsfiddle.net/DROCKS/fkmpex9u/1/[/link] As you can see the fiddle loads only the column headers but not the data due to function expected (on IE) / col.styler is not a function(Chrome) error. On tracing the same, I found out that the error was occurring in the jquery.easyui.min.js file for on the line var css=col.styler?(col.styler(_794,_791,_790)||""):""; This happened as it was not getting the highlight function. So I tried to modify the code for the same but again it was giving the same error.... Code: //var css=col.styler?(col.styler(_794,_791,_790)||""):""; //existing code Please could you tell me how to avoid that problem. Thanks in advance. Title: Re: Highlighting particular columns in the datagrid Post by: stworthy on March 27, 2016, 11:56:58 PM The 'styler' property value must be a function. Please convert it to a function before creating the datagrid.
Code: $.map(cdata[0], function(c){Title: Re: Highlighting particular columns in the datagrid Post by: Darrel on March 28, 2016, 12:45:51 AM Thanks a lot stworthy..
It worked amazingly. Thanks for your time. God bless!!! |