Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by richard white on Mar 02, 2009 12:01
open dhtmlx forum
selecting a column

hi

when the user clicks on a cell i dont want the row to be highlighted but i want all the cells in that column to be highlighted. how can i do this please, i have tried to look through your documentation and tried several methods but could not work it out

thanks

richard
Answer posted by dhxSupport on Mar 03, 2009 01:27
Unfortunately dhtmlxGrid hasn't such functionality.
Answer posted on Mar 07, 2009 12:29
do you have any work arounds where i could achieve this?
Answer posted by Support on Mar 09, 2009 04:07
Technically you can catch header click event and set custom style for all cells in the column

grid.attachEvent("onHeaderClick",function(index,e){
    grid.forEachRow(function(id){
           grid.setCellTextStyle(id, index, "background-color:red");
    })
})
Answer posted on Mar 10, 2009 08:44
this works great, thanks... except the previously selected column stays selected when we click a new column... what would be the best way to turn this off - we could do this manually by setting all cells in the previously selected column to white but the grid uses the odd row blue and white colours, therefore we want to reset it back to its original colours. is there a way to do this please?
Answer posted on Mar 10, 2009 08:56
in addition to the other question asked above, how can we attach this event to the downclick of the mouse instead the upclick as it is now?
Answer posted by Support on Mar 11, 2009 02:37
>> is there a way to do this please?
You can process all rows in the same manner , but use 
           grid.setCellTextStyle(id, index, "");
It will clear all properties assigned through style, but even|uneven colors defined through css classes, so they will not be affected by such code. 

>>how can we attach this event to the downclick of the mouse instead the upclick as it is now
Can be done only be code modification 

dhtmlxgrid.js , line 3128
this.hdr.onclick=this._onHeaderClick;

can be changed as
this.hdr.onmousedown=this._onHeaderClick;
Answer posted on Mar 11, 2009 05:49
thanks, your solutions work really well.

however, is there a way i can place the "this.hdr.onmousedown=this._onHeaderClick;" code in my template without modifying your dhtmlxgrid.js file. this is so that i wont have to keep modifying yor code each time you deliver a new update to that file

thanks

richard
Answer posted on Mar 11, 2009 05:56
i modifying just the grid i want it to work on by adding:

mygrid.hdr.onmousedown=mygrid._onHeaderClick;

thanks
     
Answer posted by Support on Mar 11, 2009 06:58
>>i modifying just the grid i want it to work on by adding:
Yes, this is the correct way
    mygrid.hdr.onclick=null; //clear old handler
    mygrid.hdr.onmousedown=mygrid._onHeaderClick;
Answer posted on Mar 11, 2009 07:02
thanks