I have an old web page that is using an ultrawebgrid. It displays the following:
In the "Value B" column, double-clicking on the 1st cell (Last Name) displays an editable text box with the value (Smith) in it. If I click on the 6th cell (Adm Code) it displays a drop down list with multiple selectable options. (Similarly, this is how the other cells in the column work as well.)
Is it possible to achieve this same functionality in either the webdatagrid or webhierarchicaldatagrid? The old page uses Javascript as follows to achieve this functionality:
function wgrid_BeforeCellChangeHandler(gridName, cellId) { var cell = igtbl_getCellById(cellId); if (cell.Column.Index == 3) { cell.Column.ColumnType = 0; cell.Column.ValueList = null; var row = cell.Row; var cell0 = row.getCell(0); var rowHeader = cell0.getValue(); if(rowHeader.toLowerCase() == 'gender') { cell.Column.ColumnType = 5; var genders = new Array(); genders[0] = new Array(); genders[0][0] = "Male"; genders[0][1] = "Male"; genders[1] = new Array(); genders[1][0] = "Female"; genders[1][1] = "Female"; genders[2] = new Array(); genders[2][0] = "Unknown"; genders[2][1] = "Unknown"; cell.Column.ValueList = genders; } else if(rowHeader.toLowerCase() == 'ethnicity') { cell.Column.ColumnType = 5; var ethnicity = new Array(); for (var i=0; i<EthnicityDescrs.length; i++) { ethnicity[i] = new Array(); ethnicity[i][0] = EthnicityDescrs[i]; ethnicity[i][1] = EthnicityDescrs[i]; } cell.Column.ValueList = ethnicity; } else if(rowHeader.toLowerCase() == 'adm code') { cell.Column.ColumnType = 5; var admissioncodes = new Array(); for (var i=0; i<AdmCodes.length; i++) { admissioncodes[i] = new Array(); admissioncodes[i][0] = AdmCodes[i]; admissioncodes[i][1] = AdmCodes[i]; } cell.Column.ValueList = admissioncodes; } } }
It changes the Column.ColumnType property as required. Can this be achieved using the editor providers?
Thank you!
Sanjay
Hello Sanjay,
Thank you for posting in our community.
It is possible to achieve the requirement by using a templated column with all of the needed editor providers. During the OnInitializeRow event you can set any of them to be visible if a condition is met.
This forum post might be of help to you.
Thank you Martin, will check the post and let you know.
I was able to create 3 item templates using the ITemplate interface and attach it to the 3 cells in the column that required different dropdown items. My problem now is once an item is selected from one of these dropdowns, how do I update the underlying webdatagrid in javascript? Is there any way to pass the grid row that the dropdown template is on to the onchange event of the dropdown so that I can update the row?
[Edit: To clarify, I need to check a check box in another cell on the same row based on the change of the itemtemplate dropdown.]
Is anyone able to assist?
I'm trying call the FindControl method on the cell containing the ITemplate instantiation, but it's not returning the drop down control:row.Items.FindItemByKey("<column key>").FindControl("ddlAdmCode")
Would appreciate it if Infragistics could respond soon, thanks.
I have created and attached a sample illustrating the desired behavior using the grid's activation behavior and a hidden column. Please test it on your side and let me know whether it helps you achieve your requirement.
If this is not an accurate demonstration of what you are trying to achieve please feel free to modify it and send it back to me along with steps to reproduce.
Looking forward to hearing from you.
6204.Sample.zip
Checking the sample, thank you. Will let you know.
Martin,
The sample provides a better approach than what we implemented - instantiating the ITemplate interface and selectively applying it to the specific cells in the column. We will use the sample approach in the future, but out of curiosity would appreciate it if you have any answers to the questions I posted earlier relating to the approach we took?
Thank you again,