Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Praveen on Jun 17, 2009 09:06
open dhtmlx forum
Splicing Columns in a Grid

Hi,
I have a TreeGrid with 6 columns. I am populating the Tree Grid using the XML based approach. Now I want to pick a particular column, say column 4 and show that single column in a new window. My original grid remains unaffected.

I would like to know if its possible to gets a single column from the grid. If yes please tell me how can I do it.
Thank you.
Answer posted by dhxSupport on Jun 18, 2009 02:44
There is no such inbuild functionality but you can do the following:
1) By clicking on the column serialize necessary column, then hide this column:

mygrid.attachEvent("onRowSelect",function(rowId,cellIndex){
  if (cellIndex==2){
  mygrid.setSerializationLevel(false,true,true);
  mygrid.setSerializableColumns("false,false,true");
  var str=mygrid.serialize();
  mygrid.setColumnHidden(cellIndex,true);
  openWindow(str,cellIndex);
  }
  });

*setSerializationLevel, setSerializableColumns,setColumnHidden - could be used only in PRO version

2) After column is hidden you can create new dhtmlxWindow, attach to it dhtmlxGrid and load grid from the serialized string:
//creating dhtmlxWindow
  dhxWins = new dhtmlXWindows();
  dhxWins.setImagePath("dhtmlxWindows/codebase/imgs/"); 

function openWindow(str,cellIndex){
  var w1 = dhxWins.createWindow("w1", 300, 50, 300, 300);
  var grid = w1.attachGrid();
  grid.parse(str);
  w1.setText(grid.getColumnLabel(0));
  dhxWins.window("w1").button("close").attachEvent("onClick",function(){
  mygrid.setColumnHidden(cellIndex,false);
  w1.close();
  });
  }


If you need working sample please contact support@dhtml.com and provide you ref. ID