Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Jacek on Dec 07, 2009 04:44
open dhtmlx forum
Grid getCombo and null value in the cell

Hello,

How to make the below snippet to work? Null is making the problem, but I need both combo and to allow null values in the column.

<div id="gridbox" style="width:500px; height:270px; background-color:white;"></div>
<script>
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setHeader("Id, Name");
mygrid.setColTypes("ed,co");

var combo = mygrid.getCombo(1);
combo.put("a");
combo.put("b");

mygrid.init();
mygrid.parse([[1,"a"], [2, null]], "jsarray");
</script>

Regards,
Jacek
Answer posted by Alex (support) on Dec 07, 2009 06:24

Hello,

try to set "null" as a string:

mygrid.parse([[1,"a"], [2,"null"]], "jsarray");

Answer posted by Stanislav (support) on Dec 07, 2009 08:56
If by null you mean the empty value, you can also try to use

mygrid.parse([[1,"a"], [2," "]], "jsarray");
Answer posted by Jacek on Dec 07, 2009 11:35
Thanks for prompt reply.

Actually the data in array comes from the database and it would be odd to have to replace all null values (which is common in databases) to empty strings manually and then to revert all "" to nulls to post back the changes. I think it is a quite common case and thus it should be handled by the library out of the box. If it's not supported how should I do it? Implement grid._process_custom_jsarray_row and call  grid.load(url,"custom_jsarray")? Is there a hook for reading values from the row to replace "" with nulls automatically?

Jacek