koteswararao
Top achievements
Rank 1
koteswararao
asked on 03 Feb 2012, 02:49 PM
hi,
i am using the telerik grid in my project with three hierarchical level i add the
CommandItemDisplay="Top" CommandItemSettings-AddNewRecordImageUrl="add.png" for all the three level grids but when i expand the all levels i didn't see any add new button at second level it appearing at first and last but missing at middle what can i dot to solve this problem
please see the attached image to see the bug
if you want full code please download from the following link download the code
i am using the telerik grid in my project with three hierarchical level i add the
CommandItemDisplay="Top" CommandItemSettings-AddNewRecordImageUrl="add.png" for all the three level grids but when i expand the all levels i didn't see any add new button at second level it appearing at first and last but missing at middle what can i dot to solve this problem
please see the attached image to see the bug
if you want full code please download from the following link download the code
3 Answers, 1 is accepted
0
Jayesh Goyani
Top achievements
Rank 2
answered on 04 Feb 2012, 09:26 AM
Hello koteswararao,
--Your whole Code------------
Thanks,
Jayesh Goyani
Protected Sub dgProduct_DetailTableDataBind(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles dgProduct.DetailTableDataBind e.DetailTableView.CommandItemDisplay = Telerik.Web.UI.GridCommandItemDisplay.Top End Sub--Your whole Code------------
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <telerik:RadGrid ID="dgProduct" runat="server" AutoGenerateColumns="false" AutoGenerateHierarchy="true" GroupingEnabled="true" AllowMultiRowSelection="false" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"> <MasterTableView EditMode="InPlace" Name="product" DataKeyNames="PKProductID" CommandItemDisplay="Top" CommandItemSettings-AddNewRecordImageUrl="add.png" CommandItemSettings-AddNewRecordText="Add New Style" AlternatingItemStyle-BackColor="#F2F3F5" ItemStyle-BackColor="#E7E7FF" CommandItemSettings-ShowRefreshButton="false" HeaderStyle-BackColor="LightGray" HierarchyLoadMode="ServerOnDemand"> <Columns> <telerik:GridBoundColumn DataField="PKProductID" HeaderText="PKProductID" Visible="false" /> <telerik:GridEditCommandColumn UniqueName="Edit" ButtonType="ImageButton" CancelText="cancel" EditText="edit" InsertText="insert"> </telerik:GridEditCommandColumn> <telerik:GridTemplateColumn HeaderText="Title"> <ItemTemplate> <%#Eval("Language1Title")%> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="txtColorTitle" runat="server" Text='<%#Eval("Language1Title") %>' ReadOnly="true"></asp:TextBox> </EditItemTemplate> </telerik:GridTemplateColumn> </Columns> <DetailTables> <telerik:GridTableView DataMember="colors" HierarchyLoadMode="ServerOnDemand" Name="Colors" DataKeyNames="pkproductid" Width="300px" CommandItemDisplay="Top" CommandItemSettings-AddNewRecordImageUrl="add.png" CommandItemSettings-AddNewRecordText="Add New Size" AlternatingItemStyle-BackColor="#F2F3F5" CommandItemSettings-ShowRefreshButton="false" ItemStyle-BackColor="#E7E7FF" HeaderStyle-BackColor="LightGray"> <Columns> <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn1"> <HeaderStyle Width="80px" /> <ItemStyle CssClass="MyImageButton" /> </telerik:GridEditCommandColumn> <telerik:GridBoundColumn DataField="PKProductid" HeaderText="PKProductid" Visible="false" /> <telerik:GridTemplateColumn HeaderText="Title"> <ItemTemplate> <%#Eval("Language1Title")%> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="txtColorTitle" runat="server" Text='<%#Eval("Language1Title") %>' ReadOnly="true"></asp:TextBox> </EditItemTemplate> </telerik:GridTemplateColumn> </Columns> <DetailTables> <telerik:GridTableView DataMember="Sizes" HierarchyLoadMode="ServerOnDemand" Width="300px" Name="sizes" DataKeyNames="pkproductid" CommandItemDisplay="Top" CommandItemSettings-AddNewRecordImageUrl="add.png" CommandItemSettings-AddNewRecordText="Add New Size" AlternatingItemStyle-BackColor="#F2F3F5" CommandItemSettings-ShowRefreshButton="false" ItemStyle-BackColor="#E7E7FF" HeaderStyle-BackColor="LightGray"> <Columns> <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn1"> <HeaderStyle Width="80px" /> <ItemStyle CssClass="MyImageButton" /> </telerik:GridEditCommandColumn> <telerik:GridBoundColumn DataField="PKProductid" HeaderText="PKProductid" Visible="false" /> <telerik:GridTemplateColumn HeaderText="Title"> <ItemTemplate> <%#Eval("Language1Title")%> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="txtSizeTitle" runat="server" Text='<%#Eval("Language1Title") %>' ReadOnly="true"></asp:TextBox> </EditItemTemplate> </telerik:GridTemplateColumn> </Columns> </telerik:GridTableView> </DetailTables> </telerik:GridTableView> </DetailTables> <EditFormSettings> <EditColumn Reorderable="false" Resizable="false" /> </EditFormSettings> </MasterTableView> </telerik:RadGrid>Public Class WebForm1 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load dgProduct.DataSource = createDataset() End Sub Public Function createDataset() As DataSet Dim dtMain As DataTable = New DataTable() Dim dtcolumn1 As DataColumn = New DataColumn("pkproductid", GetType(Integer)) Dim dtcolumn2 As DataColumn = New DataColumn("fkproductid", GetType(Integer)) Dim dtcolumn3 As DataColumn = New DataColumn("Language1Title", GetType(String)) dtMain.Columns.Add(dtcolumn1) dtMain.Columns.Add(dtcolumn2) dtMain.Columns.Add(dtcolumn3) ''Color data Dim dtColor As DataTable = New DataTable() Dim dtcolumn11 As DataColumn = New DataColumn("pkproductid", GetType(Integer)) Dim dtcolumn21 As DataColumn = New DataColumn("fkproductid", GetType(Integer)) Dim dtcolumn31 As DataColumn = New DataColumn("Language1Title", GetType(String)) dtColor.Columns.Add(dtcolumn11) dtColor.Columns.Add(dtcolumn21) dtColor.Columns.Add(dtcolumn31) ''Size data Dim dtSize As DataTable = New DataTable() Dim dtcolumn12 As DataColumn = New DataColumn("pkproductid", GetType(Integer)) Dim dtcolumn22 As DataColumn = New DataColumn("fkproductid", GetType(Integer)) Dim dtcolumn32 As DataColumn = New DataColumn("Language1Title", GetType(String)) dtSize.Columns.Add(dtcolumn12) dtSize.Columns.Add(dtcolumn22) dtSize.Columns.Add(dtcolumn32) For i = 0 To 3 Dim drowmain As DataRow = dtMain.NewRow() Dim strProduct As String = "1" & i drowmain(0) = Convert.ToInt32(strProduct) drowmain(1) = DBNull.Value drowmain(2) = "mainproduct" Dim drowColor As DataRow = dtColor.NewRow() Dim strcolor As String = "4" & i drowColor(0) = Convert.ToInt32(strcolor) drowColor(1) = Convert.ToInt32(strProduct) drowColor(2) = "colorProduct" Dim drowdtSize As DataRow = dtSize.NewRow() Dim strdtSize As String = "5" & i drowdtSize(0) = Convert.ToInt32(strdtSize) drowdtSize(1) = Convert.ToInt32(strcolor) drowdtSize(2) = "sizeProduct" dtMain.Rows.Add(drowmain) dtColor.Rows.Add(drowColor) dtSize.Rows.Add(drowdtSize) dtMain.AcceptChanges() dtColor.AcceptChanges() dtSize.AcceptChanges() Next Dim ds As DataSet = New DataSet() ds.Tables.Add(dtMain) ds.Tables.Add(dtColor) ds.Tables.Add(dtSize) ds.AcceptChanges() ds.Relations.Add(New DataRelation("main-color", dtMain.Columns(0), dtColor.Columns(1))) ds.Relations.Add(New DataRelation("color-size", dtColor.Columns(0), dtSize.Columns(1))) Return ds End Function Protected Sub dgProduct_DetailTableDataBind(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles dgProduct.DetailTableDataBind e.DetailTableView.CommandItemDisplay = Telerik.Web.UI.GridCommandItemDisplay.Top End SubEnd ClassThanks,
Jayesh Goyani
0
koteswararao
Top achievements
Rank 1
answered on 04 Feb 2012, 10:53 AM
hi Jayesh Goyani,
Thank you the problem was solved with you great supporting , i got another problem now can you please see the scenario
when i click on the edit one column contain dropdown this was filled with another datasource
based on the dropdown selected value other two columns in the same row is filled the values filled with correct values when i click on edit ,
but when comes to insert (insert new record) case there the drop down was filled with object datasource values the first item is selected but when in this case i want to fill the two textboes on the same row with corresponding to the dropdown value when use manually change the item in the drop down the values are fill in the text box correctly , same thing we do at first time also
means we want to raise the selected change event of the drop down when we click on new record button
Thanks & Regards,
m.koteswara Rao
Thank you the problem was solved with you great supporting , i got another problem now can you please see the scenario
when i click on the edit one column contain dropdown this was filled with another datasource
based on the dropdown selected value other two columns in the same row is filled the values filled with correct values when i click on edit ,
but when comes to insert (insert new record) case there the drop down was filled with object datasource values the first item is selected but when in this case i want to fill the two textboes on the same row with corresponding to the dropdown value when use manually change the item in the drop down the values are fill in the text box correctly , same thing we do at first time also
means we want to raise the selected change event of the drop down when we click on new record button
Thanks & Regards,
m.koteswara Rao
0
Hello Koteswararao,
You could achieve your scenario by subscribing to the Grid ItemCommand event and checking if the CommandName is RadGrid.InitInsertCommandName and implementing the same logic that is in the drop down SelectedIndexChanged event. I have assembled a sample code that demonstrates the described solution.
All the best,
Antonio Stoilkov
the Telerik team
You could achieve your scenario by subscribing to the Grid ItemCommand event and checking if the CommandName is RadGrid.InitInsertCommandName and implementing the same logic that is in the drop down SelectedIndexChanged event. I have assembled a sample code that demonstrates the described solution.
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e){ if (e.CommandName == RadGrid.InitInsertCommandName) { //implement same logic as in the SelectedIndexChange of the drop down }}All the best,
Antonio Stoilkov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>