Need to establish the relationship between the master table and detail tables. I am using "GridRelationFields" but because ajax error. When not using the "GridRelationFields" I click to expand the detail of a record and I get all the detailed tables of all records.
I mention that each detail table differ in the number of columns and their names, each table are aggregated in a programmatic way.
How I can successfully establish the relationship between the master table and detail table?
I noted the examples online and do not help me.
Annex the image of the error in AJAX when using "GridRelationFields. "
This is my code to build the tables in detail:
I mention that each detail table differ in the number of columns and their names, each table are aggregated in a programmatic way.
How I can successfully establish the relationship between the master table and detail table?
I noted the examples online and do not help me.
Annex the image of the error in AJAX when using "GridRelationFields. "
This is my code to build the tables in detail:
DataTable datTabDatosDetalle =
new
DataTable();
if
(ViewState[
"OrdCompraProdDetallesSub"
+ IdOrdenCompra + Skucode] ==
null
)
{
datTabDatosDetalle = CCSMovimientoProductos.BuscarProdDetOrdenCompra_CEDIS(IdOrdenCompra, Skucode).Tables[0];
ViewState.Add(
"OrdCompraProdDetallesSub"
+ IdOrdenCompra + Skucode, datTabDatosDetalle);
}
else
datTabDatosDetalle = (DataTable)ViewState[
"OrdCompraProdDetallesSub"
+ IdOrdenCompra + Skucode];
Telerik.Web.UI.GridTableView detailTable =
new
Telerik.Web.UI.GridTableView(radGriOrdComDetalles);
Telerik.Web.UI.GridRelationFields relationFields_Id =
new
Telerik.Web.UI.GridRelationFields();
relationFields_Id.MasterKeyField =
"Id"
;
relationFields_Id.DetailKeyField =
"Id"
;
detailTable.ParentTableRelation.Add(relationFields_Id);
Telerik.Web.UI.GridRelationFields relationFields_Skucode =
new
Telerik.Web.UI.GridRelationFields();
detailTable.ParentTableRelation.Add(relationFields_Skucode);
relationFields_Skucode.MasterKeyField =
"prodSkucode"
;
relationFields_Skucode.DetailKeyField =
"prodSkucode"
;
radGriOrdComDetalles.MasterTableView.DetailTables.Add(detailTable);
detailTable.Name =
"tabDetail"
+ IdOrdenCompra + Skucode;
detailTable.DataKeyNames =
new
string
[] {
"prodSkucode"
};
detailTable.EnableViewState =
true
;
detailTable.NoDetailRecordsText =
""
;
detailTable.Caption =
"Detalle del producto Sku "
+ Skucode;
detailTable.EditMode = Telerik.Web.UI.GridEditMode.InPlace;
foreach
(DataColumn dc
in
datTabDatosDetalle.Columns)
{
Telerik.Web.UI.GridBoundColumn campo =
new
Telerik.Web.UI.GridBoundColumn();
detailTable.Columns.Add(campo);
campo.UniqueName =
"col"
+ dc.ColumnName;
campo.HeaderText =
"[ "
+ dc.ColumnName +
" ]"
;
campo.HeaderStyle.Font.Bold =
true
;
campo.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
campo.DataField = dc.ColumnName;
if
(dc.ColumnName ==
"Id"
)
{
campo.Visible =
false
;
}
if
(dc.ColumnName ==
"prodSkucode"
)
{
campo.Visible =
false
;
}
if
(dc.ColumnName ==
"Talla"
)
{
campo.ReadOnly =
true
;
}
}
Telerik.Web.UI.GridEditCommandColumn campoEdit =
new
Telerik.Web.UI.GridEditCommandColumn();
detailTable.Columns.Add(campoEdit);
campoEdit.UniqueName =
"colEdit"
;
campoEdit.ButtonType = Telerik.Web.UI.GridButtonColumnType.LinkButton;
campoEdit.EditText =
"Editar"
;
campoEdit.UpdateText =
"Actualizar"
;
campoEdit.CancelText =
"Cancelar"
;
detailTable.DataSource = datTabDatosDetalle;
detailTable.Rebind();
radGriOrdComDetalles.Rebind();