This is a migrated thread and some comments may be shown as answers.

GridDropDownColumn - How Do I Get the Value During Update?

3 Answers 222 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bryan Kowalchuk
Top achievements
Rank 1
Bryan Kowalchuk asked on 30 May 2011, 07:12 PM
I have a radgrid that looks like:

<
telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="MultiEmployeeList" AutoGenerateColumns="False"
    CellSpacing="0" GridLines="None" GroupingEnabled="False" AllowMultiRowEdit="false"
    AutoGenerateEditColumn="True"  HorizontalAlign="Left"Width="800px">
    <ClientSettings>
        <ClientEvents OnCommand="OnCommand" />
    </ClientSettings>
    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
    </HeaderContextMenu>
    <MasterTableView DataSourceID="MultiEmployeeList" DataKeyNames="rasID" ClientDataKeyNames="rasID"
        EditMode="InPlace">
        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
            <HeaderStyle Width="20px"></HeaderStyle>
        </RowIndicatorColumn>
        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
            <HeaderStyle Width="20px"></HeaderStyle>
        </ExpandCollapseColumn>
        <Columns>
            <telerik:GridBoundColumn DataField="empName" FilterControlAltText="Filter column column"
                UniqueName="Name" ReadOnly="true">
            </telerik:GridBoundColumn>
            <telerik:GridDropDownColumn DataField="rasRoleID" DataSourceID="RoleList" FilterControlAltText="Filter column column"
                ListTextField="mrrRoleDesc" ListValueField="mrrID" UniqueName="rasRoleID" EmptyListItemText=" -- Select Role --"
                EnableEmptyListItem="True"  >
            </telerik:GridDropDownColumn>
        </Columns>
        <EditFormSettings>
            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
            </EditColumn>
        </EditFormSettings>
    </MasterTableView>
    <FilterMenu EnableImageSprites="False">
    </FilterMenu>
</telerik:RadGrid>

I do an AJAX-type webservice post during update, and it all works fine.
My question is, how can I find the value of the combo box the user has selected during update so I can post this back using a web service?
I can get the key value of the row, but finding the new selected value (rasRoleID) is eluding me.

Thanks.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 31 May 2011, 05:46 AM
Hello Bryan,

Try the following code snippet by attaching UpdateCommand event to your RadGrid.

C#:
protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
 {
   if (e.Item is GridEditableItem && e.Item.IsInEditMode)
  {
    GridEditableItem item = e.Item as GridEditableItem;
    string Employee = (item["rasRoleID"].Controls[0] as RadComboBox).SelectedItem.Text;
   }
}

Thanks,
Princy.
0
Bryan Kowalchuk
Top achievements
Rank 1
answered on 06 Jun 2011, 03:13 PM
Thanks for the reply, but is there any way to get dropdown column value client-side during the OnCommand or other client-side event?
0
Bryan Kowalchuk
Top achievements
Rank 1
answered on 06 Jun 2011, 07:05 PM
I found the solution. Below is the javascript required:

    function OnCommand(sender, args) {
    args.set_cancel(false);
    if (args.get_commandName() == 'Update') {
        //Get the value, update the service
        var key = sender.get_masterTableView().get_dataItems()[args.get_commandArgument()].getDataKeyValue("rasID");
        var radGridElement = $get('RadGrid1');
        var radRole = $telerik.findControl(radGridElement, "rasRoleID");
        var rasRoleValue = radRole.get_selectedItem().get_value();
        //Update the webservice
        //Create the JSON object
        var request = {};
        request['Source'] = 'MultiRatingRole';
        request['Type'] = 'Update';
        request['Key'] = key;
        request['Value'] = rasRoleValue;
        Service.ProcessRequest(JSON.stringify(request));
    }
}
Tags
Grid
Asked by
Bryan Kowalchuk
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Bryan Kowalchuk
Top achievements
Rank 1
Share this question
or