dhtlmxCombo in Gridcell

Hi, after the perfect implementation of the dhtmlxCombobox on my site (thanx for that!), I came across an opportunity to try the Grid function next.



Unfortunately I’m having some difficulty understanding some functions/options, so I hope you can help me again.



First of, I’m trying to implement the dhtlmxCombobox in a column (or actually multiple columns) with the use of filtering.

Since I’m using Coldfusion (and my XML knowledge is slim-to-none) I was going for the ‘convert an HTML table to Grid’ option, as follows:

































































Id fk_company_id fk_employee_id employeename fk_function_id functionname fk_firm_id firmname from_fk_project_id from_projectcode from_dateend to_fk_project_id to_projectcode to_datestart to_dateend remarks informed requeststatus
#id# #fk_company_id#

             



<option value="#ucase(qEmployeesInfo.id)#" selected>#NiceCharCrop(lastname & ', ’ & initials,40)#

<cfset form.employeename = lastname & ', ’ & initials>





#employeename# #fk_function_id# #functionname# #fk_firm_id# #firmname# #from_fk_project_id# #from_projectcode# #from_dateend# #to_fk_project_id# #to_projectcode# #to_datestart# #to_dateend# #remarks# #informed# #requeststatus#








I don’t have a clue on how to make the third column an dhtmlcombobox…



The second question is probably easier:

Is it possible to use ‘hidden’ columns? (still using the convert option)



The third question, will I be able to read all the data from the cells and save them to the database? Since I’m not using an XML-file…



Cheers,

Chris

First of, I’m trying to implement the dhtlmxCombobox in a column
Next code need to be updated


as


next one


need to be replaced with




and next lines added to js script section
function set_combo(){
var combo = mygrid.getCombo(2);

combo.put("#qEmployeesInfo.id#","#NiceCharCrop(lastname & ', ’ & initials,40)#");

};


>>Is it possible to use ‘hidden’ columns? (still using the convert option)
The PRO version of grid supports
grid.setColumnHidden
command. So you can convert existing table to the grid and hide necessary columns after that.

>>will I be able to read all the data from the cells and save them to the database? Since I’m not using an XML-file…
The API of grid works the same for all ways of initialization, so all existing data access API will work in case of init from HTML.




<option value="#ucase(qEmployeesInfo.id)#" selected>#NiceCharCrop(lastname & ', ’ & initials,40)#
<cfset form.employeename = lastname & ', ’ & initials>


#EmployeesInfo.id#

First of thanks for the quick reply!
Now I’m at least able to use a combo in my grid!

Having said that, the given code gave me some problems though:



function set_combo(){
� � �var combo = mygrid.getCombo(2);
� � ��
� � �� � �combo.put("#qEmployeesInfo.id#","#NiceCharCrop(lastname & ‘, ’ & initials,40)#");
� � �
};

The “onbeforeinit” occurs before the grid has been made, so the call to “set_combo” doesn’t work, because the function contains “mygrid”, which hasn’t been initialized yet…

But I’ve altered the code into the following:













Id employeename
#id# #employeename#





 


This gives me a combobox in the grid, it’s not quite the same as the dhtlmxCombo on my other screens, but it almost suffices.
There are still a few strange things though:
- the employeename, which was first added to the table, is added to the bottom of the list, instead of selecting the one from the list.
- The combo is case sensitive, this is not a serious problem, but it’s not consistent with the rest
- I’m able to input anything, even if not in the selection list and leave the cell without having a valid option. I fixed this with the normal dhtmlxCombo by using this :
if (combo.getActualValue()==combo.getComboText()) //non existing option entered

{
   form.combostatus.value=‘Reset’;
   combo.setComboValue("#form.employeeid#");
}
else if (form.combostatus.value == ‘Reset’)
{
   frmProject.combostatus.value=’’; 
}
But this doesn’t apply here…

Now I’ve still have to focus on how that API works, I’ve still got no clue on how to get all the griddata and save it back to the database…

Cheers,
Chris


because the function contains “mygrid”, which hasn’t been initialized yet…
yes, was a my typo, the correct code will be
function set_combo(){
var combo = datagrid.getCombo(2);
while “mygrid” is still not created you can use id of souce table (“datagrid” in you case ) as reference for grid object.

>>- the employeename, which was first added to the table, is added to the bottom of the list, instead of selecting the one from the list.

#employeename# - here you need to use ID, not combo ( to work correctly it requires to call set_combo from before_init as well )

- value/label pairs loaded during grid init ( onbeforeinit)
- grid loads data from table and convert values to labels ( ID to name)

>>- I’m able to input anything, even if not in the selection list and leave the cell without having a valid option
Change column type to
mygrid.setColTypes("ed,ed,coro

>>This gives me a combobox in the grid, it’s not quite the same as the dhtlmxCombo
Actually it is not the dhtmlxCombo, it is a “co” column type - built in combo of dhtmlxGrid
To have real combo in grid, you need to use column type “combo”, getCellCombo instead of getCombo, and addOption instead of put method