Hello, are there any demos/examples of dynamically creating the pop-up edit form for a grid? I found the demo for the pop-up edit form but the EditFormSettings tag is defined in the code front; I need to dynamically create the fields available for the user to edit.
Each record in the grid will have several "static" columns, but can also have other fields that will vary from user to user. I'd like the grid to display just the static columns, and then clicking "Edit" will bring up a pop-up edit form with those static fields AND any dynamic fields available to the user.
If this can't be done with a grid could someone please suggest something that could handle this?
Thanks,
Aaron
Each record in the grid will have several "static" columns, but can also have other fields that will vary from user to user. I'd like the grid to display just the static columns, and then clicking "Edit" will bring up a pop-up edit form with those static fields AND any dynamic fields available to the user.
If this can't be done with a grid could someone please suggest something that could handle this?
Thanks,
Aaron
8 Answers, 1 is accepted
0
Hi abonfig,
You can use FormTemplate/UserControl to instantiate any static or dynamic template/control. The grid pop-up edit form will work flawlessly with all three modes: auto-generated, template and user control edit forms.
Best wishes,
Vlad
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
You can use FormTemplate/UserControl to instantiate any static or dynamic template/control. The grid pop-up edit form will work flawlessly with all three modes: auto-generated, template and user control edit forms.
Best wishes,
Vlad
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
abonfig
Top achievements
Rank 1
answered on 21 Oct 2008, 02:46 PM
Thank you. I have a follow up question.
If I am using a UserControl as the pop-up edit form, and I need to set a property of that UserControl based on the row that I am editing, in what grid event can I set that property in before the UserControl is loaded?
If I am using a UserControl as the pop-up edit form, and I need to set a property of that UserControl based on the row that I am editing, in what grid event can I set that property in before the UserControl is loaded?
0
Princy
Top achievements
Rank 2
answered on 22 Oct 2008, 10:37 AM
Hello,
Try setting the property for the usercontrol in the ItemCreated or ItemDataBound event of the grid. Check out the sample code shown below.
cs:
Thanks
Princy.
Try setting the property for the usercontrol in the ItemCreated or ItemDataBound event of the grid. Check out the sample code shown below.
cs:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridEditFormItem && e.Item.IsInEditMode) |
{ |
GridEditFormItem item = e.Item as GridEditFormItem; |
// get the index of the row |
string strtxt = e.Item.ItemIndex.ToString(); |
// access the user control |
UserControl user = item.FindControl(GridEditFormItem.EditFormUserControlID) as UserControl; |
// code to set the property of user control |
} |
} |
Thanks
Princy.
0
abonfig
Top achievements
Rank 1
answered on 24 Oct 2008, 08:51 PM
Thanks, Princy.
Is there any examples out there for setting the property of the UserControl? I can get a reference to it using that code, but am not sure how to set the specific property. It is not available in Intellisense.
Is there any examples out there for setting the property of the UserControl? I can get a reference to it using that code, but am not sure how to set the specific property. It is not available in Intellisense.
0
abonfig
Top achievements
Rank 1
answered on 24 Oct 2008, 08:51 PM
Thanks, Princy.
Is there any examples out there for setting the property of the UserControl? I can get a reference to it using that code, but am not sure how to set the specific property. It is not available in Intellisense.
Is there any examples out there for setting the property of the UserControl? I can get a reference to it using that code, but am not sure how to set the specific property. It is not available in Intellisense.
0
abonfig
Top achievements
Rank 1
answered on 27 Oct 2008, 08:10 PM
Hello,
I've figured out how to access and set the UserControl's property. My next question is how to determine if the user has clicked the "Edit" button or the "Add New Record" on the grid. I am binding the grid to a custom business object (Address). In the OnItemCreated event, e.Item.DataItem can be cast to this type when I am editing a row, but when I click to add a new row the Telerik "GridInsertionItem" cannot be case to type Address. My OnItemCreated event looks like this:
Controls_AddressEditForm addressEditForm = (Controls_AddressEditForm) item.FindControl(GridEditFormItem.EditFormUserControlID);
I've figured out how to access and set the UserControl's property. My next question is how to determine if the user has clicked the "Edit" button or the "Add New Record" on the grid. I am binding the grid to a custom business object (Address). In the OnItemCreated event, e.Item.DataItem can be cast to this type when I am editing a row, but when I click to add a new row the Telerik "GridInsertionItem" cannot be case to type Address. My OnItemCreated event looks like this:
public
void rgAddresses_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditFormItem item = e.Item as GridEditFormItem;
// access the user control
Controls_AddressEditForm addressEditForm = (Controls_AddressEditForm) item.FindControl(GridEditFormItem.EditFormUserControlID);
// code to set the property of user control
addressEditForm.CurrentAddress = (Address)e.Item.DataItem;
// Call the UserControl's method for populating itself
addressEditForm.PopulateFields();
}
}
0
Hello abonfig,
You can determine this by checking e.Item.OwnerTableView.IsItemInserted, to determine if the control is in insert mode (add new record). The e.Item.IsInEditMode will address the other query.
I hope this helps.
Greetings,
Yavor
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
You can determine this by checking e.Item.OwnerTableView.IsItemInserted, to determine if the control is in insert mode (add new record). The e.Item.IsInEditMode will address the other query.
I hope this helps.
Greetings,
Yavor
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Princy
Top achievements
Rank 2
answered on 28 Oct 2008, 06:52 AM
Hello,
You can also refer the Insert Form items as GridEditInsertFormItem to access the InsertFormUserControl as shown below.
cs:
Thanks
Princy.
You can also refer the Insert Form items as GridEditInsertFormItem to access the InsertFormUserControl as shown below.
cs:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted) |
{ |
GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item; |
//code to access the user control code and set the property of user control goes here |
} |
} |
Thanks
Princy.