Categories | Question details Back To List | ||
DataGrid Hi! datagrid header label's are not aligned to center.I have written one generic method inorder to pass all the required stuffs.Below mention is my sample code: function loadData(tabObject,tabId,tabLabelName,tabPixels,dataGridDivId,header,headerColAlignArray,subHeader,subHeaderColAlignArray,cellWidth,colTypes,colAlign,dataGridObject,hideDivArray,showDivArray,windowObject,responseData,isTreeGrid){ //hideDivObjects disable child div tags for parent div tag if(hideDivArray!=null) hideDivObjects(hideDivArray); if(tabObject==null&&tabId!=null&&tabLabelName!=null&&tabPixels!=null){ tabObject=windowObject.attachTabbar(); tabObject.setImagePath(uri+"dhtmlxTabbar/codebase/imgs/"); tabObject.addTab(tabId,tabLabelName,tabPixels); tabObject.enableAutoSize(false,true); } else if(tabObject!=null&&tabId!=null&&tabLabelName!=null&&tabPixels!=null&&document.getElementById(dataGridDivId).style.display=="none") { tabObject.addTab(tabId,tabLabelName,tabPixels); tabObject.enableAutoSize(false,true); } if(tabId!=null&&tabLabelName!=null&&tabPixels!=null) { tabObject.showTab(tabId); tabObject.setStyle("light"); tabObject.setTabActive(tabId); tabObject.setContent(tabId,dataGridDivId); tabObject.enableAutoReSize(false) ; tabObject.setOnSelectHandler(onSelectTab); } //showDivObjects enable parent div tags if(showDivArray!=null){ showDivObjects(showDivArray); } dataGridObject= new dhtmlXGridObject(dataGridDivId); dataGridObject.setImagePath(uri+'dhtmlxGrid/codebase/imgs/'); if(header!=null&&headerColAlignArray!=null) dataGridObject.setHeader(header,null,[headerColAlignArray]); if(subHeader!=null&&subHeaderColAlignArray!=null) dataGridObject.attachHeader(subHeader,[subHeaderColAlignArray]); dataGridObject.setInitWidths(cellWidth); dataGridObject.setColAlign(colAlign); dataGridObject.setColTypes(colTypes); dataGridObject.setSkin("light"); dataGridObject.enableTreeCellEdit(false); dataGridObject.init(); if(isTreeGrid) { dataGridObject.loadXMLString(responseData,function(){ dataGridObject.expandAll()}); } else{ dataGridObject.loadXMLString(responseData); } if(windowObject!=null) { windowObject.setModal(true); windowObject.show(); } var arr=new Array(tabObject,dataGridObject); return arr; } this function loadData I am calling in below mention function: function outputResponse(loader) { if(loader.xmlDoc.responseText !=null) { setInitialHeight("summary_container"); var empemail=document.changeUser.email.value; var accessType=document.changeUser.accessType.value; var hideDivArray=new Array("toolbarObj","tab_container","tab_contents","tab_node_contents","tab_node_alloc_contents"); var showDivArray=new Array("summary_container"); //loadData(tabObject,tabId,tabLabelName,tabPixels,dataGridDivId,header,headerColAlignArray,subHeader,subHeaderColAlignArray,cellWidth,colTypes,colAlign,dataGridObject,hideDivArray,showDivArray,windowObject,responseData,isTreeGrid) var arr=loadData(null,null,null,null,"summary_container","Goal,#cspan,#cspan,Bookings,#cspan,Backlog,Revenue,#cspan,Commission,#cspan,#cspan",new Array("text-align:center;font-size:2","text-align:center;font-size:2","text-align:center;font-size:2","text-align:center;font-size:2","text-align:center;font-size:2"),"Description,Goal,CUR,Bookings(USD),My Comm Bookings,My Comm Backlog,My Comm Revenue,% Goal (Rev),ICC Estimate,ICC Paid,Estimated/Future Pmt",new Array("text-align:center","text-align:center","text-align:center","text-align:center","text-align:center","text-align:center","text-align:center","text-align:center","text-align:center","text-align:center","text-align:center"),"*,85,30,95,95,80,95,40,65,55,55","tree,ro,ro,link,ro,link,ro,ro,ro,ro,ro","left,right,center,right,right,right,right,right,right,right,right",summarygrid,hideDivArray,showDivArray,null,loader.xmlDoc.responseText,true); summarygrid=arr[1]; getHeight("summary_container",summarygrid.getRowsNum(),80) loadingEnded(); } } Answer posted by Support on Feb 20, 2009 06:57 Instead of dataGridObject.setHeader(header,null,[headerColAlignArray]); dataGridObject.attachHeader(subHeader,[subHeaderColAlignArray]); You need to use dataGridObject.setHeader(header,null,headerColAlignArray); dataGridObject.attachHeader(subHeader,subHeaderColAlignArray); currently you defining array two times - once when loadData called ( new Array ) and second time when setHeader command executed ( [] ) Answer posted by ravi on Feb 22, 2009 20:59 thanks ....its working fine |