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

To show different msg for Details table button and parent record button

3 Answers 44 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amit
Top achievements
Rank 1
Amit asked on 25 Aug 2010, 12:17 PM
I have a grid with parent record and detailstable records.Detail table record will be shown only if we have child record other wise single record with no child record is shown.

In parent record and detail table child record i have button.And i'm setting msg on these buttons.The parent record should show msg that deleting parent record will delete child record as well where as deleting child record will show msg do you want to delete this record msg.

Where should i put this validation.Should i use DetailTableDataBind event for this.If yes then how should i find the parent control button to change the msg if no records are found and keep the the same msg if i have the records for child detail table
 

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 25 Aug 2010, 02:19 PM
Hello Amit,

You can try the following code snippet in PreRender event to achieve this.

C#:
protected void RadGrid1_PreRender(object sender, EventArgs e)
   {
       foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
       {
           GridTableView tableView = (GridTableView)item.ChildItem.NestedTableViews[0];
           int count = tableView.Items.Count;
           Button btn = (Button)item["GridButtonColumn"].Controls[0]; //accessing button in parent record
           if (count == 0)
           {
               btn.Attributes.Add("onclick", "return confirm('Do you want to delete this record?')");
           }
           else
           {
               btn.Attributes.Add("onclick", "return confirm('Deleting parent record will delete child record as well, do you want to proceed ?')");
           }
        }
   }

Thanks,
Princy.
0
Amit
Top achievements
Rank 1
answered on 26 Aug 2010, 12:10 PM
Thanks For your answer.
Button btn = (Button)item["GridButtonColumn"].Controls[0];//accessing button in parent record
This button seems to be using the databound control,to bind the button.
Where as my button is a delete button.and not bound by the database record.

My code requirement is such that my delete button is deleting record on delete button.And show the msg.
I even override the javascript msg as you have done, but it eventually override the delete business logic and my delete button funtionality doesn't work after i override the msg. If don't override the msg then my code works fine and records are deleted as well. 
Plz help
0
Mira
Telerik team
answered on 31 Aug 2010, 03:06 PM
Hello Amit,

The provided information is not enough for us to fully understand your scenario. Could you please provide little bit more details?
Is the Delete button generated from a GridButtonColumn with CommandName="Delete"? Do you want the "deleting parent record will delete child record as well" message to be used as an alert or a confirmation?
What type of data binding do you use? How is deleting implemented?

Sending us a sample project will be highly appreciated.

All the best,
Mira
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Amit
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Amit
Top achievements
Rank 1
Mira
Telerik team
Share this question
or