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

Radgrid display confirmation message

1 Answer 472 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jagat
Top achievements
Rank 1
Jagat asked on 30 Mar 2017, 07:28 PM

Hi,

I want to display a message when i click on a row in radgrid.

With the code, i have, i can display the message. Now, if the user clicks on OK, I want to perform one method and if he cancels, i want to perform another method.

How do i know what the user clicked on?

<telerik:RadGrid runat="server" ID="rg_OnlineDownloads" AutoGenerateColumns="false"
                                OnNeedDataSource="rg_OnlineDownloads_NeedDataSource"
                                onitemcommand="rg_OnlineDownloads_ItemCommand" >
                                <MasterTableView DataKeyNames="HouseholdID">
                                    <Columns>
                                        <telerik:GridBoundColumn DataField="ApplicationDate" HeaderText="ApplicationDate">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="HouseholdID" HeaderText="HouseholdID">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="ClientName" HeaderText="ClientName">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="FamilyMembers" HeaderText="#nbrs">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="ClientAddress" HeaderText="ClientAddress">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="CellPhone" HeaderText="CellPhone">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridButtonColumn UniqueName="Transfer" CommandName="Transfer" ConfirmText="" ConfirmDialogType="RadWindow"
                                           ConfirmTitle="Transfer to Intake"  ButtonType="PushButton" > </telerik:GridButtonColumn>
                                    </Columns>
                                </MasterTableView>
                            </telerik:RadGrid>

 

Code Behind:

protected void rg_OnlineDownloads_ItemCommand(object sender, GridCommandEventArgs e)
     {
         if (e.CommandName == "Transfer")// CommandName of LinkButton
         {
             GridDataItem dataItem = e.Item as GridDataItem;
             string hHoldID = dataItem["HouseholdID"].Text;
             string clntNm = dataItem["ClientName"].Text;  
             (rg_OnlineDownloads.MasterTableView.GetColumn("Transfer") as GridButtonColumn).ConfirmText =
                 "Do you want to transfer " + clntNm + " ? ";
 
              
         }
     }
 

 

Thanks in Advance

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 04 Apr 2017, 12:24 PM
Hi Jagat,

Basically, you can achieve this requirement using a GridTemplateColumn:

1. Place a Button or RadButton inside and disable its AutoPostBack property
2. Place a RadWindowManager on the page if you don't want to use the default window confirm method
3. Using the client-side Click event handler of the button, call radconfirm method:
http://docs.telerik.com/devtools/aspnet-ajax/controls/window/alert,-confirm,-prompt-dialogs/radconfirm-dialog
4. Get the result in the corresponding callback function 
5. Call a grid command depending on the user's selection:
http://www.telerik.com/help/aspnet-ajax/grid-gridtableview-firecommand.html

Also, you can check the attached web sites for other implementations.

Regards,
Eyup
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Jagat
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or