Hi,
I have problem with data manipulation in "detail grid".
I have typed DataSet that is binded to MasterDataGrid....that master data grid has 5 columns that are related with 5 fields from one table (MasterTable) but, when i click on Edit in some row, then within <EditFormSettings EditFormType="Template"> i have offered to modify other columns from MasterTable...all key values for masterGrid i suggest within masterGrid_ItemCommand (if e.CommandName == RadGrid.InitInsertCommandName)...
then i have added detailGrid inside that EditFromSettings...
now the problem appear...when i try to use that detailGrid, i can't find it as control in masterGrid, so i can't add row in that grid...even if I add row (with button that has CommandName="PerformInsert"), that command line simply dissapear in grid...like i didn't add it at all...
If i explained it little bit confusy here is some code that will help me to be more precise:
<telerik:RadGrid id="masterGrid" runat="server" AllowMultiRowSelection="false" AutoGenerateEditColumn="true" AutoGenerateColumns="False" DataMember="MasterTable" DataSourceID="someDataSource" GridLines="None" OnItemCommand="masterGrid_ItemCommand"> | |
<IxMasterTableView DataKeyNames="Col1,Col2,Col3" DataMember="MasterTable" DataSourceID="someDataSource" SelectionItemDisplay="TopAndBottom" AllowSorting="True" AutoGenerateColumns="False" CommandItemDisplay="Top"> | |
<CommandItemTemplate> some button is here </CommandItemTemplate> | |
<Columns> | |
<telerik:GridBoundColumn DataField="Column1" HeaderText="Column1 name" ReadOnly="True" SortExpression="Column1" UniqueName="Column1" /> | |
and 4 columns more... | |
</Columns> | |
<EditFormSettings EditFormType="Template"> | |
<FormTemplate> | |
<table> | |
<tr><td>...some TextBox binded columns....</td><tr> | |
<tr> | |
<td> | |
<telerik:RadGrid ID="detailGrid" runat="server" SelectionEnabled="False" DataSourceID="someDataSource" GridLines="None" DataMember="DetailTable" AutoGenerateColumns="False" AllowSorting="True" OnItemCommand="detailGrid_ItemCommand"> | |
<IxMasterTableView DataKeyNames="Col1,Col2,Col3,Col4,Col5" DataMember="DetailTable" DataSourceID="someDataSource" SelectionItemDisplay="TopAndBottom" AllowSorting="True" AutoGenerateColumns="False" CommandItemDisplay="Top"> | |
<CommandItemTemplate> some button is here </CommandItemTemplate> | |
<Columns> | |
<telerik:GridTemplateColumn HeaderText="first" UniqueName="Col1" DataField="Col1" SortExpression="Col1"> | |
<ItemTemplate> | |
...some link button... | |
</ItemTemplate> | |
<EditItemTemplate> | |
...some TextBox control... | |
</EditItemTemplate> | |
<telerik:GridTemplateColumn> | |
...and couple more GridTemplateControls... | |
...and last column in grid is something like this... | |
<telerik:GridTemplateColumn UniqueName="ColumnDelete"> | |
<ItemTemplate> | |
<asp:Button ID="deleteButton" runat="server" Text="Del" CommandName="Delete" /> | |
</ItemTemplate> | |
<EditItemTemplate> | |
<asp:Button ID="addButton" Text="Add" Visible='<%# don't know how to implement as it is in masterGrid %>' runat="server" CommandName="PerformInsert" /> | |
<asp:Button ID="updateButton" Text="Update" Visible='<%# same as previous, just on update %>' runat="server" CommandName="Update" /> | |
<asp:Button ID="cancelButton" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel" /> | |
</EditItemTemplate> | |
<HeaderStyle /> | |
<ItemStyle HorizontalAlign="Right" /> | |
</telerik:GridTemplateColumn> | |
</Columns> | |
</telerik:RadGrid> | |
</td> | |
</tr> | |
<tr> | |
<td> | |
<asp:Button ID="addMaster" Text="Add" Visible='<%# (masterGrid.IxMasterTableView.IsItemInserted) %>' runat="server" CommandName="PerformInsert" /> | |
<asp:Button ID="updateMaster" Text="Update" Visible='<%# !(masterGrid.IxMasterTableView.IsItemInserted) %>' runat="server" CommandName="Update" /> | |
<asp:Button ID="cancelMaster" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel" /> | |
</td> | |
</tr> | |
</table> | |
</FormTemplate> | |
</EditFormSettings> | |
</IxMasterTableView> | |
</telerik:RadGrid> |
and here is some codebehind for onItemCommand
DataKey oldKeyValues = e.Item.OwnerTableView.DataKeyValues[0]; | |
RadGrid detailRadGrid = (sender as RadGrid); | |
if (e.CommandName == RadGrid.InitInsertCommandName) { | |
detailRadGrid.Save(false); | |
aoGridCommandEventArgs.Canceled = true; | |
System.Collections.Specialized.ListDictionary newKeyValues = new System.Collections.Specialized.ListDictionary(); | |
if (loDataKey != null) { | |
newKeyValues["Col1"] = oldKeyValues["Col1"]; | |
newKeyValues["Col2"] = oldKeyValues["Col2"]; | |
newKeyValues["Col3"] = oldKeyValues["Col3"]; | |
newKeyValues["Col4"] = oldKeyValues["Col4"]; | |
e.Item.OwnerTableView.InsertItem(newKeyValues); | |
} | |
} |
same is for masterGrid...
So, my question would be...how can i add and save value in detailGrid, because this way it is not functioning, and is it possible to filter detailGrid rows to display only rows that are related to masterGrid column that is not in KeyColumns ?
and how can i check which row in rows 33 and 34 (of first code part) will be visible based on logic in rows 46 and 47 ?
Some example of how to use this would be great...i'm stuck here fot 10 days and can't move any further...
Thanks for reply...