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

External LinkButton

4 Answers 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 1
Ian asked on 27 Jul 2010, 06:56 PM
Hi. Is there any way that I can get a LinkButton that's on the same page as a Grid to generate an 'InitInsert' command so that a new grid row can be entered by a user? For UI design reasons, I'm not able to include the LinkButton within a Grid CommandItemTemplate - it needs to be a separate LinkButton that's located in the page sidebar.
Regards.

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 27 Jul 2010, 10:15 PM
Hello Ian,

You could put the RadGrid in insert mode using the InitInsert method:
protected void Button1_Click1(object sender, EventArgs e)
{
    RadGrid1.MasterTableView.InsertItem();
}

Regards,
Daniel
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
0
Ian
Top achievements
Rank 1
answered on 28 Jul 2010, 09:43 AM
Hi Daniel,
That partially worked although using your solution didn't seem to fire the RadGrid1_ItemCommand event so the code to hide the EditColumn wasn't executed. I got around this by including it in the LinkButton click handler:

protected void Button1_Click1(object sender, EventArgs e)
{
RadGrid1.MasterTableView.InsertItem();
GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn");
editColumn.Visible = false;
}

Is that the best solution or is there a way to actually fire the ItemCommand event from an external control?
Regards, Ian


0
Daniel
Telerik team
answered on 04 Aug 2010, 09:35 AM
Hello Ian,

It is also possible to fire the InitInsert command manually:
RadGrid1.MasterTableView.Items[0].FireCommandEvent("InitInsert", "");

Regards,
Daniel
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
0
Ian
Top achievements
Rank 1
answered on 05 Aug 2010, 06:30 PM
Daniel,
Hi. That works perfectly. Thanks.
A suggestion: It might be worth adding a link in the 'Getting familiar with server-side API' section of the Grid documentation - this discusses all of the properties and events for the Grid but nothing about its methods. I never thought to look in the 'Control lifecycle' section of the  documentation where I now realise the FireCommandEvent is described!
Thanks again, Ian
Tags
Grid
Asked by
Ian
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Ian
Top achievements
Rank 1
Share this question
or