Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by cesler on Mar 26, 2009 10:47
open dhtmlx forum
This is the 'script still running" line 126 in dhtmlxcalendar.js

<script type="text/javascript">
var mygrid;
function doInitGrid() {
mygrid = new dhtmlXGridObject('mygrid_container');
mygrid.setImagePath("DataTables/fsTable/imgs/");
mygrid.setHeader("Date,Name,City,State,Price,Description,Type,Mech");
mygrid.setInitWidths("75,175,75,50,75,175,125,50");
mygrid.setColAlign("right,right,right,right,left,right,right,right")
mygrid.setSkin("modern");
mygrid.enableCSVAutoID(true);
mygrid.setColSorting("date,str,str,str,int,str,str,str");
mygrid.setColTypes("dhxCalendar,ed,ed,ed,ed,ed,ed,ed");
mygrid.attachEvent("onRowSelect", doOnRowSelected);
mygrid.init();
mygrid.load("DataTables/fsTable/transaction.csv","csv");
         mygrid.sortRows(1,"date","des");
}

function addRow() {
var newId = (new Date()).valueOf()
mygrid.addRow(newId, "", mygrid.getRowsNum())
mygrid.selectRow(mygrid.getRowIndex(newId), false, false, true);
}
function removeRow() {
var selId = mygrid.getSelectedId()
mygrid.deleteRow(selId);
}

function doOnRowSelected(rowID, celInd) {
alert("Selected row ID is " + rowID + "\nUser clicked cell with index " + celInd);
}
</script>
Answer posted by dhxSupport on Mar 27, 2009 06:15

In the method sortRows(col, type, order) first parameter - colum index. In the grid first column index is "0". Also you should call this method after grid was fully loaded:

mygrid.load("DataTables/fsTable/transaction.csv",function(){
  mygrid.sortRows(0,"date","des");
 },"csv");