10 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 19 Jan 2011, 06:32 AM
Hello,
Here is a sample aspx code snippet which shows FormTemplate in Detailtable.
ASPX:
Thanks,
Princy.
Here is a sample aspx code snippet which shows FormTemplate in Detailtable.
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid2"
. . .>
<
MasterTableView
Name
=
"Master"
. . .>
<
Columns
>
. . . . . .
</
Columns
>
<
DetailTables
>
<
telerik:GridTableView
Name
=
"Detail2"
runat
=
"server"
AutoGenerateColumns
=
"false"
CommandItemDisplay
=
"Top"
DataKeyNames
=
"TerritoryID"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"EmployeeID"
UniqueName
=
"EmployeeID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"TerritoryID"
UniqueName
=
"TerritoryID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridButtonColumn
CommandName
=
"Delete"
Text
=
"Delete"
>
</
telerik:GridButtonColumn
>
<
telerik:GridEditCommandColumn
UniqueName
=
"EditCommandColumn"
>
</
telerik:GridEditCommandColumn
>
</
Columns
>
<
EditFormSettings
EditFormType
=
"Template"
>
<
FormTemplate
>
TerritoryID
<
asp:TextBox
ID
=
"TextBox1"
runat
=
"server"
Text='<%#Bind("TerritoryID") %>'></
asp:TextBox
>
<
br
/>
<
asp:LinkButton
ID
=
"Linkbutton1"
runat
=
"server"
Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'></
asp:LinkButton
>
<
asp:LinkButton
ID
=
"Linkbutton2"
runat
=
"server"
CommandName
=
"Cancel"
>Cancel</
asp:LinkButton
>
</
FormTemplate
>
</
EditFormSettings
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"EmployeeID"
MasterKeyField
=
"EmployeeID"
/>
</
ParentTableRelation
>
</
telerik:GridTableView
>
</
DetailTables
>
</
MasterTableView
>
</
telerik:RadGrid
>
Thanks,
Princy.
0

RJ
Top achievements
Rank 1
answered on 19 Jan 2011, 07:16 PM
Thank you for your response.
Can the template fields be validated?
Can we have additional fields that are not bound to the grid (detail table) in the template. If yes, how can these fields be manually updated programmatically(which event).
Is there an easy way to validate the entire form template.
Thank you
Can the template fields be validated?
Can we have additional fields that are not bound to the grid (detail table) in the template. If yes, how can these fields be manually updated programmatically(which event).
Is there an easy way to validate the entire form template.
Thank you
0

Princy
Top achievements
Rank 2
answered on 20 Jan 2011, 08:31 AM
Hello,
You can easily validate the control in FormTemplate by adding Validation control to corresponding control. The following demo shows how to add validation controls. You can use the same approach here.
You can add aditional fields in FormTemplate(which is not bound to DetailTable, but must be in DataSourse of DetailTable). And in UpdateCommand, check for the row in hierarchy and update corresponding row. Sample code is given below.
C#:
Thanks,
Princy.
You can easily validate the control in FormTemplate by adding Validation control to corresponding control. The following demo shows how to add validation controls. You can use the same approach here.
You can add aditional fields in FormTemplate(which is not bound to DetailTable, but must be in DataSourse of DetailTable). And in UpdateCommand, check for the row in hierarchy and update corresponding row. Sample code is given below.
C#:
protected
void
RadGrid1_UpdateCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.Item.OwnerTableView.Name ==
"DetailTable"
)
//check with name of GridTableView to identify grid row in hierarchy.
{
//code for updating record in DetailTable.
}
}
Thanks,
Princy.
0

RJ
Top achievements
Rank 1
answered on 20 Jan 2011, 02:25 PM
Thank you, but how do I get the fields that are not bound to the grid and they are part of the datasource. Can I do a custom validation which calls another method to validate the field.
Can I have a separate FormTemplate for insert and edit.The insert has additional fields which are not part of the grid and need to be handled while inserting the record.
Thanks
Can I have a separate FormTemplate for insert and edit.The insert has additional fields which are not part of the grid and need to be handled while inserting the record.
Thanks
0

Princy
Top achievements
Rank 2
answered on 21 Jan 2011, 08:49 AM
Hello,
I guess you are asking about getting the fields in UpdateCommand. Since you are adding these additional fields in FormTemplate, you can access it in UpdateCommand by accessing that control first and then its value.
Yes, you can add CustomValidator to controls in FormTemplate. Then you don't need a separate FormTemplate for insert and edit form. If you have additional fields in insert form, hide it in edit form like below.
ASPX:
Thanks,
Princy.
I guess you are asking about getting the fields in UpdateCommand. Since you are adding these additional fields in FormTemplate, you can access it in UpdateCommand by accessing that control first and then its value.
Yes, you can add CustomValidator to controls in FormTemplate. Then you don't need a separate FormTemplate for insert and edit form. If you have additional fields in insert form, hide it in edit form like below.
ASPX:
<
FormTemplate
>
TerritoryID
<
asp:TextBox
ID
=
"TextBox1"
runat
=
"server"
Text='<%#Bind("TerritoryID") %>'
Visible='<%#(Container.DataItem is Telerik.Web.UI.GridInsertionObject) %>'></
asp:TextBox
>
</
FormTemplate
>
Thanks,
Princy.
0

RJ
Top achievements
Rank 1
answered on 21 Jan 2011, 03:57 PM
Thank you, but the additional fields are not bound to the grid and they are not in the data source. Is there anyway to identify/show these additional fields in the template for insert only.
A few additional fields are required during the insert and the logic to insert the values from these additional fields will be handled programmatically in the insert command event.
Thanks
A few additional fields are required during the insert and the logic to insert the values from these additional fields will be handled programmatically in the insert command event.
Thanks
0

Princy
Top achievements
Rank 2
answered on 24 Jan 2011, 10:36 AM
Hello ,
The following ASPX code add the TextBox only in insert form(setting Visibility directly in aspx page).
ASPX:
You can also hide the TextBox from code behind by checking whether the grid is in edit/insert mode.
ASPX:
C#:
.
Thanks,
Princy.
The following ASPX code add the TextBox only in insert form(setting Visibility directly in aspx page).
ASPX:
<
FormTemplate
>
<
asp:TextBox
ID
=
"TextBox1"
runat
=
"server"
Visible='<%#(Container.DataItem is Telerik.Web.UI.GridInsertionObject) %>'></
asp:TextBox
>
</
FormTemplate
>
You can also hide the TextBox from code behind by checking whether the grid is in edit/insert mode.
ASPX:
<
DetailTables
>
<
telerik:GridTableView
Name
=
"Detail2"
>
<
EditFormSettings
EditFormType
=
"Template"
>
<
FormTemplate
>
<
asp:TextBox
ID
=
"TextBox1"
runat
=
"server"
></
asp:TextBox
>
</
FormTemplate
>
. . . . . . . .
</
DetailTables
>
C#:
protected
void
RadGrid2_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditFormItem && e.Item.IsInEditMode && e.Item.OwnerTableView.Name ==
"Detail2"
)
//check with the Name of DetailTable to identify the row in hierarchy
{
if
(!e.Item.OwnerTableView.IsItemInserted)
{
GridEditFormItem item = (GridEditFormItem)e.Item;
TextBox txtbox = (TextBox)item.FindControl(
"TextBox1"
);
txtbox.Visible =
false
;
// hiding TextBox if it is in edit form
}
}
}
Thanks,
Princy.
0

RJ
Top achievements
Rank 1
answered on 09 Feb 2011, 12:56 PM
Hi,
I'm using RAD window to insert the detail table records. How can I refresh/rebind the detail table (grid) when the RAD window is closed.
Thanks
I'm using RAD window to insert the detail table records. How can I refresh/rebind the detail table (grid) when the RAD window is closed.
Thanks
0

RJ
Top achievements
Rank 1
answered on 10 Feb 2011, 12:15 AM
I'm using the Rebind method on the MasterTableView and Detail table as shown below. It is triggering the correct events but the grid does not refresh with the correct data. What is the best way to refresh the Detail table after an Insert from the Radwindow. Any suggestions would be greatly appreciated.
Radgrid1.Rebind :
This is triggering the event Radgrid_NeedDataSource.
Radgrid.Mastertableview.Items(0).Childitem.NestedTableViews(0).Rebind :
This is triggering the Radgrid_DetailTableDataBind and the datasource is assigned with the added record. However, the grid does not display the newly added record.
Thank you
Radgrid1.Rebind :
This is triggering the event Radgrid_NeedDataSource.
Radgrid.Mastertableview.Items(0).Childitem.NestedTableViews(0).Rebind :
This is triggering the Radgrid_DetailTableDataBind and the datasource is assigned with the added record. However, the grid does not display the newly added record.
Thank you
0

Shinu
Top achievements
Rank 2
answered on 10 Feb 2011, 01:33 PM
Hello,
Radgrid.Mastertableview.Items(0).Childitem.NestedTableViews(0).Rebind will rebind the nested tableview of first grid item. Check whethr you have rebind the correct nested TableView.
The following code snippet loops through each ChildTableView and Rebind it.
-Shinu.
Radgrid.Mastertableview.Items(0).Childitem.NestedTableViews(0).Rebind will rebind the nested tableview of first grid item. Check whethr you have rebind the correct nested TableView.
The following code snippet loops through each ChildTableView and Rebind it.
For
Each
item
As
GridDataItem
In
RadGrid1.Items
Dim
tableView
As
GridTableView =
DirectCast
(item.ChildItem.NestedTableViews(0), GridTableView)
' rebind DetailTable of all item
tableView.Rebind()
Next
-Shinu.