Hello there,
a new day, new problems: On a row I have label with text, when the users wants to edit this row, I want to show a webdropdown and set the text in the dropdown as selected item.
I Found a example how to make this work and tinkered this:
In the RowEditTemplate
<td> <%--<div style="width: 160px; z-index: 1000000">--%> <stgwc:DropDown ID="ddlRoleTypeEdit" ClientIDMode="Static" DisplayMode="DropDownList" TextField="RoletypeDescription" DropDownItemBinding-TextField="RoletypeDescription" ValueField="RoleTypeCode" DropDownItemBinding-ValueField="RoletypeDescription" EnableLoadOnDemand="false"runat="server" Width="150px" EnableDropDownAsChild="true" OnInit="DropDown_OnPreRender" > </stgwc:DropDown> <%--</div>--%> </td>
At the binding I set this:
<ig:RowEditingClientBinding ColumnKey="RoleType" ControlID="ddlRoleTypeEdit" SetValueJavaScript="$find({ClientID}).set_currentValue(cell.get_element().innerText,true)" />
When I debug I see this works not bad so far, I guess the problem is the clientstate list, which doesnt seem filled at this time.
Is there anything else I have to look at to make this work proper?
Thanks for your response
Matthias
Hello Matthias,
Thank you for posting your solution on the forum.
I hope it will be useful for other users too.
Since I needed a solutation, I tinkered it in the worst possible way.
Here is the code:
//Set DropDown value manually, since the DataGrid events dont shoot when we enter the edit mode with the function var roleTypeDescr = tr.find('>:nth-child(3)').children(0).find(':nth-child(2)')[0].innerText; var ddl = $find('ddlRoleTypeEdit'); var ds = ddl._dataStore[2][0]; var itemIndex; jQuery.each(ds, function (indx, value) { if (ds[indx][0][1] == roleTypeDescr) { itemIndex = indx; return; } }); if (itemIndex) ddl.selectItemByIndex(itemIndex, true, true);
It works at the moment, so I guess I let it that way.
The problem lies in the clientStaateManager I think. To be exact, here:
$IG.ObjectClientStateManager.prototype ={ get_value:function(id, isBool) { ///
/// returns a value from client-state /// ///id of the value to get from client-state ///if the value returned is boolean or not /// var index = id[0]; var defaultVal = id[1]; var val = this._transactionList.get_value(index);
the val is undefined at this point since the propsIndex doesnt seem to fit.
Can I kinda reload the clientstatemanager to get the correct values?
EDIT: Is it possible a problem when I load the dropdown.
I do this on the INIT event:
<stgwc:DropDown ID="ddlRoleTypeEdit" ClientIDMode="Static" DisplayMode="DropDownList" TextField="DESCR" DropDownItemBinding-TextField="DESCR" ValueField="ROLETYPE_CDE" DropDownItemBinding-ValueField="ROLETYPE_CDE" runat="server" Width="150px" EnableDropDownAsChild="true" OnInit="DropDown_OnPreRender" > </stgwc:DropDown>
And in code behind:
ddlControl.DataSource = GetRoleTypes(); ddlControl.TextField = "DESCR"; ddlControl.ValueField = "ROLETYPE_CDE"; ddlControl.DataBind();
As you can see at the naming, I tried OnPreRender, but this causes other problems.
Might there be a problem?
Hello Alex,
I cant use the {value} tag, since I work with templates.
I guess the problem is not what I pass but when the dropdown fills all its items.
Can I force to load them all? I guess that would solve the problem.
I have created a sample based on your description to test this behavior.
When the following bindings for the dropdown column are used the text is inserted in the grid in this sample:
<ig:RowEditingClientBinding ColumnKey="Item" ControlID="WebDropDown1" GetValueJavaScript="$find({ClientID}).get_selectedItem().get_text()" SetValueJavaScript="$find({ClientID}).set_currentValue({value},true)" />
<ig:RowEditingClientBinding ColumnKey="Item" ControlID="WebDropDown1" GetValueJavaScript="$find({ClientID}).get_selectedItem().get_text()"
SetValueJavaScript="$find({ClientID}).set_currentValue({value},true)" />
Test this on you sample and update me with the results.