I have a dhtmlxgrid on my rails app. The grid is working fine but now I need to add a combobox to it and, even after reading all the help on their support foruns and all the documentation, I can't seem to get it working...
Right now I set the column as a combobox, and it's being populated with the current value set on the database. But that column has two possible values. what I need is for the cell to be populated with: first the selected value on the database, but also list the second option if they want to change.
Here's my current code
view.html.erb
<script type="text/javascript" charset="utf-8">
var grid = new dhtmlXGridObject("grid_here");
grid.setImagePath("../assets/dhtmlx/imgs/");
grid.setHeader("Status");
grid.attachHeader("#text_filter");
grid.setColTypes("coro");
grid.setColSorting("str");
grid.setInitWidths("60");
grid.setSkin("dhx_skyblue");
grid.init();
grid.load("/data");
grid.attachEvent("onCheck",doOnCheckBoxSelected);
dp = new dataProcessor("/dbaction.xml");
dp.init(grid);
</script>
data.xml.builder
xml.instruct! :xml, :version=>"1.0"
xml.tag!("rows") do
@products.each do |product|
xml.tag!("row",{ "id" => product.id }) do
xml.tag!("cell", product.status)
end
end
end
Any idea on how to do this?
You can set options on the client side or define them as part of xml data. Check the next article in the dhtmlx's documentation
http://docs.dhtmlx.com/doku.php?id=dhtmlxgrid:initialization_from_xml
For init on client side it look like next
grid.getCombo(0).put("1", "First Option")
grid.getCombo(0).put("1", "Second Option")