Mediv Posted April 3, 2012 Share Posted April 3, 2012 Hi Farshad. Can I make a coloring of the grid, the first line - white, the next - gray, etc. as indicated in the following example: http://dev.sencha.com/deploy/ext-4.0.1/examples/grid/array-grid.html I was watching your example CellDraw, there is an appeal to the server, I would like to do it on the client side. Thank you. Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted April 3, 2012 Administrators Share Posted April 3, 2012 Try this for DBGrid.ExtEvents onReconfigure JS Event: function OnReconfigure(sender, store, colModel) { colModel.getColumnById(1).renderer=function(val) { return '<span style="color:green;">' + val + '</span>'; }; } Quote Link to comment Share on other sites More sharing options...
Mediv Posted April 3, 2012 Author Share Posted April 3, 2012 Hi Farshad. Sorry. I'm probably not quite correct to explain my question, I want to change the background color of entire rows, the first line - white, the next - gray, etc. not a color value in the cell. Thank you. Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted April 3, 2012 Administrators Share Posted April 3, 2012 For each column you need to write a proper renderer function in JS. function OnReconfigure(sender, store, colModel) { colModel.getColumnById(1).renderer=function(val, metadata, rec, row, col, store) { if (row==0) metadata.attr='style="background-color:green;"'; return val; }; colModel.getColumnById(2).renderer=function(val, metadata, rec, row, col, store) { metadata.attr='style="background-color:green;"'; return val; }; } Quote Link to comment Share on other sites More sharing options...
Mediv Posted April 3, 2012 Author Share Posted April 3, 2012 I do not know where Js, help me understand! I want to loop through the rows and columns, the columns did, the problem with strings. colModel.getColumnCount () returns the number to the columns. colModel.getRowCount () returns a count of rows? Or maybe I have an error in the other? function OnReconfigure (sender, store, colModel) { for (i = 0; i <colModel.getColumnCount() -1; i + +) { colModel.getColumnById (i). renderer = function (val, metadata, rec, row, col, store) { for (j = 0; k = 0; j <colModel.getRowCount () -1; j + +) { if (row == k) { metadata.attr = 'style = "background-color: grey;"'; k = k + 2; }; return val; }; }; }; } Thank you. Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted April 3, 2012 Administrators Share Posted April 3, 2012 You should not loop inside the renderer function. Renderer function is called per each cell. You don't need using a loop there. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.