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

RadGrid - Delete Confirm JavaScript and Get Values of the DataField of the ClientDataKeyNames

1 Answer 138 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chi Ming
Top achievements
Rank 1
Chi Ming asked on 20 Jun 2013, 07:44 PM

Hello everyone,

i need your help for getting the value of the DataField from ClientDataKeyNames array of the MasterTable and even without AllowRowSelect = "True" 
All I need is to CLICK BUTTON ONLY WITHOUT AllowRowSelect = True 
Once I click "Remove Location" button, I am still getting error that we don't get any values from ClientDataKeyName.  

In UserControl 
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
        <script type="text/javascript">
            function OnClientClickingApprovedLocations(sender, args) {
                var callBackFunction2 = Function.createDelegate(sender, function (argument) {
                    if (argument) {
                        this.click();
                    }
                });
 
                var Master = $find("<%=rgRequestorlocations.ClientID %>").get_masterTableView();
                var SelectedItem = Master.get_selectedItems()[0];
 
                var location_name = SelectedItem.getDataKeyValue("location_name"); // get the DataKeyValue of selected item
                var role = SelectedItem.getDataKeyValue("role");
                var duty = SelectedItem.getDataKeyValue("duty");
 
 
                if (duty == "P") {
                    if (role == "Privacy Officer") {
 
                        roletext = "Are you sure you want to remove this role location?";
                        radconfirm(roletext, callBackFunction2, 300, 100, null, "Delete");
                        args.set_cancel(true);
                    }
                    else {
                        roletext = "Please confirm the Primary " + role + " for " + location_name + " will be removed " + "" + "?";
                        radconfirm(roletext, callBackFunction2, 300, 100, null, "Delete");
                        args.set_cancel(true);
                    }
 
                }
                else {
                    roletext = "Are you sure you want to remove this role location?";
                    radconfirm(roletext, callBackFunction2, 300, 100, null, "Delete");
                    args.set_cancel(true);
                }
            }
        </script>
    </telerik:RadScriptBlock>

<telerik:RadGrid ID="rgRequestorlocations" runat="server" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" OnNeedDataSource="rgRequestorlocations_NeedDataSource" OnItemCommand="rgRequestorlocations_ItemCommand" OnItemDataBound="rgRequestorlocations_ItemDataBound">
                                            <MasterTableView DataKeyNames="location_pk, user_id, role,location_name, duty" ClientDataKeyNames="location_pk, user_id, role,location_name, duty">
 
                                                <CommandItemSettings ExportToPdfText="Export to PDF" />
                                                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True">
                                                    <HeaderStyle Width="20px" />
                                                </RowIndicatorColumn>
                                                <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
                                                    <HeaderStyle Width="20px" />
                                                </ExpandCollapseColumn>
                                                <Columns>
                                                    <telerik:GridBoundColumn DataField="user_id" FilterControlAltText="Filter location_pk column" HeaderText="User ID" UniqueName="user_id" Visible="False"></telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="location_pk" FilterControlAltText="Filter location_pk column" HeaderText="Location ID" UniqueName="location_pk" Visible="False"></telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="location_name" FilterControlAltText="Filter location_name column" HeaderText="Location Name" UniqueName="location_name"></telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="role" FilterControlAltText="Filter role column" HeaderText="Role" UniqueName="role"></telerik:GridBoundColumn>
                                                    <telerik:GridBoundColumn DataField="duty" FilterControlAltText="Filter role column" HeaderText="duty" UniqueName="duty" Visible="false"></telerik:GridBoundColumn>
                                                    <%--             <telerik:GridButtonColumn ButtonType="PushButton" FilterControlAltText="Filter deletecolumn column" ConfirmText="Are you sure you want to remove this role location?"
                                ConfirmDialogType="RadWindow"
                                ConfirmTitle="Remove Role Location?" HeaderText="Remove Role" Text="Remove Role" UniqueName="deletecolumn" CommandName="DeleteRoleLocation">
                            </telerik:GridButtonColumn>--%>
                                                    <telerik:GridTemplateColumn UniqueName="rbDelete">
                                                        <ItemTemplate>
                                                            <telerik:RadButton ID="rbDelete" onr runat="server" Text="Remove Role" OnClientClicking="OnClientClickingApprovedLocations" Value="" CommandName="DeleteRoleLocation">
                                                            </telerik:RadButton>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                </Columns>
                                                <EditFormSettings>
                                                    <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                                                </EditFormSettings>
                                                <PagerStyle PageSizeControlType="RadComboBox" />
                                            </MasterTableView>
                                            <PagerStyle PageSizeControlType="RadComboBox" />
                                            <ClientSettings>
                                                <Selecting AllowRowSelect="True"></Selecting>
 
                                            </ClientSettings>
 
                                            <FilterMenu EnableImageSprites="False"></FilterMenu>
                                        </telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 25 Jun 2013, 09:05 AM
Hello Chi,

Please run the attached web site which demonstrates a similar functionality and let me know if it helps you. The implemented approach does not depend on the selected item and the application will work as expected even with disabled selection:
<ClientSettings>
    <Selecting AllowRowSelect="false" />
</ClientSettings>

Hope this helps.

Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Chi Ming
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or