Anto (DLL Version : 2008.3.1314.35)
Top achievements
Rank 2
Anto (DLL Version : 2008.3.1314.35)
asked on 11 Jul 2013, 02:52 PM
Hi All
Have a RadGrid with AutoGenerateColumn ="true" and EditMode="InPlace".
have a datatable with some flag. If the flag is 1 need to hide the Textbox in EditMode.
Have to compare with the datatable and hide the Textbox.
Need to know whether there is any option to hide the Textbox.
-Anto
Have a RadGrid with AutoGenerateColumn ="true" and EditMode="InPlace".
have a datatable with some flag. If the flag is 1 need to hide the Textbox in EditMode.
Have to compare with the datatable and hide the Textbox.
Need to know whether there is any option to hide the Textbox.
-Anto
4 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 12 Jul 2013, 04:06 AM
Hi Anto,
I guess you want to hide columns in edit mode.Please try the following code snippet.
C#:
Thanks,
Princy
I guess you want to hide columns in edit mode.Please try the following code snippet.
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="true" onitemcommand="RadGrid1_ItemCommand"> <MasterTableView EditMode="InPlace"> </MasterTableView> </telerik:RadGrid>C#:
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == RadGrid.EditCommandName) { //Your conditons RadGrid1.MasterTableView.GetColumn("ColumnName").Visible = false; //Hide a column in Edit mode } }Thanks,
Princy
0
Anto (DLL Version : 2008.3.1314.35)
Top achievements
Rank 2
answered on 12 Jul 2013, 09:44 AM
Hi Princy,
This is hide the whole column.
I need to hide that particular Textbox, especially only for that row.
-Anto
This is hide the whole column.
I need to hide that particular Textbox, especially only for that row.
-Anto
0
Princy
Top achievements
Rank 2
answered on 15 Jul 2013, 05:41 AM
Hi Anto,
Please try the following code snippet.
C#:
Thanks,
Princy
Please try the following code snippet.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e){ if (e.Item is GridEditableItem && e.Item.IsInEditMode) { GridEditableItem edititem = (GridEditableItem)e.Item; //Your Conditions { TextBox txtbx = (TextBox)edititem["DataField"].Controls[0];//Column for the textbox to be hidden txtbx.Visible = false; } }}Thanks,
Princy
0
Anto (DLL Version : 2008.3.1314.35)
Top achievements
Rank 2
answered on 16 Jul 2013, 11:51 AM
Princy,
Thank You for your valuable reply.
I solved the issue by.
This worked fine.
-Anto
Thank You for your valuable reply.
I solved the issue by.
protected void RadGridSingleClick_PreRender(object sender, EventArgs e) { string Textboxhide = Session["ChkRowColumnID"].ToString(); string[] arrayTextboxHide = Textboxhide.Split(','); int[] arrayID = new int[arrayTextboxHide.Length - 1]; string[] arrayUniqueName = new string[arrayTextboxHide.Length - 1]; for (int loopi = 0; loopi < arrayTextboxHide.Length - 1; loopi++) { string[] arrayIdandUniqueName = arrayTextboxHide[loopi].Split('|'); arrayID[loopi] = Convert.ToInt32(arrayIdandUniqueName[0]); arrayUniqueName[loopi] = arrayIdandUniqueName[1]; } //To reduce the Width of the textbox in Edit Mode. foreach (GridEditableItem edititem in RadGridSingleClick.MasterTableView.GetItems(GridItemType.EditItem)) { foreach (GridColumn col in RadGridSingleClick.MasterTableView.RenderColumns) { if (col.ColumnType == "GridBoundColumn")//Checking for BoundColumn { if (edititem.IsInEditMode) { TextBox txtbx = (TextBox)edititem[col.UniqueName].Controls[0]; txtbx.Width = Unit.Pixel(50); //Setting width string EditedColumnMKTID = edititem.GetDataKeyValue("MKTID").ToString(); string ColumnHeaderEdit = col.UniqueName; int columnnumbertoedit = edititem.RowIndex; for (int looptohideTextbox = 0; looptohideTextbox < arrayID.Length; looptohideTextbox++) { if (columnnumbertoedit == arrayID[looptohideTextbox] + 2 && ColumnHeaderEdit == arrayUniqueName[looptohideTextbox]) { //Anto to hide Text Box txtbx.Visible = false; } } } } } } }This worked fine.
-Anto