Hello,
I would like to report what I believe is a bug in the split grid. I managed to reduce the test scenario to the following steps:
- Create a grid with 2 columns
- Freeze column 0 (split grid at column 1)
- Set the column types to ‘co’ and sorting type to ‘str’
- Populate the combos with some values
- Add two rows to the grid, using empty cells
- Set some values for the 4 cells using the combos, so that all cells have a value
- Sort grid by the left column
Expected result: the grid rows should be sorted by the values in the first column; the values in the first column should be preserved.
Actual result: the grid is not sorted. The values are shown in view mode, however when editing the cells they are added at the bottom of the combo list with an option value of “” (empty string). So the values are actually lost upon sorting.
A few more details:
- this only happens on the left side of the split (only for the frozen columns). In my example, sorting by the right column works just fine
- this only happens if the initial value of the cell is not part of the combo values defined for the cell (in particular, if the initial value is empty)
- it seems to be happening only for combo cells and only for str sort (but of that I’m not sure)
As a workaround, I took care of always prefilling the combo cells with the first option in the combo, rather than leaving them empty – but this is not always an acceptable solution.
Here’s the code to reproduce the bug:
<html>
<head>
<link rel="stylesheet" type="text/css" href="/dhx/dhtmlxGrid/codebase/dhtmlxgrid.css">
<link rel="stylesheet" type="text/css" href="/dhx/dhtmlxGrid/codebase/skins/dhtmlxgrid_dhx_skyblue.css">
<script src="/dhx/dhtmlxGrid/codebase/dhtmlxcommon.js"></script>
<script src="/dhx/dhtmlxGrid/codebase/dhtmlxgrid.js"></script>
<script src="/dhx/dhtmlxGrid/codebase/dhtmlxgridcell.js"></script>
<script src="/dhx/dhtmlxGrid/codebase/ext/dhtmlxgrid_splt.js"></script>
</head>
<body>
<div id="gridbox" style="width:200px;height:86px;background-color:white;"></div>
<script>
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("/dhx/dhtmlxGrid/codebase/imgs/");
mygrid.setHeader("Left Column,Right Column");
mygrid.setInitWidths("100,100");
mygrid.setColAlign("left,left");
mygrid.setColTypes("co,co");
for (var i = 1; i <= 10; i++) {
mygrid.getCombo(0).put("leftvalue" + i, "leftvalue" + i);
mygrid.getCombo(1).put("rightvalue" + i, "rightvalue" + i);
}
mygrid.setColSorting("str,str");
mygrid.setSkin("dhx_skyblue");
mygrid.init();
mygrid.splitAt(1);
mygrid.addRow((new Date()).valueOf(), "");
mygrid.addRow((new Date()).valueOf(), "");
</script>
</body>
</html>
I’m using a registered version of dhtmlxGrid v.2.5 Professional edition build 91111.
Please advise.
Thanks!
Radu Galesanu