Hi,
I have a requirement where in we show a grid with 100+ columns all with GridTemplateColumns. We either have TextBox, Dropdwon or Radiobutton as edit item template for all the columns. We have a feature where in we invoke a RadWindow (Kept as Content Template with in the same Grid Page) that opens up where in user is shown a drop down that has all the columns that are shown in the grid on selection of any column we need to show the appropriate edit item control for the selected column where in user can enter/select data.
For example if user select "Name" in dropdown, I need to show TextBox if edit item template has text box and if user "Department" in dropdown, I need to show Dropdwon if edit item template has dropdwon...
Looking forward for help
Thanks in Advance
I have a requirement where in we show a grid with 100+ columns all with GridTemplateColumns. We either have TextBox, Dropdwon or Radiobutton as edit item template for all the columns. We have a feature where in we invoke a RadWindow (Kept as Content Template with in the same Grid Page) that opens up where in user is shown a drop down that has all the columns that are shown in the grid on selection of any column we need to show the appropriate edit item control for the selected column where in user can enter/select data.
For example if user select "Name" in dropdown, I need to show TextBox if edit item template has text box and if user "Department" in dropdown, I need to show Dropdwon if edit item template has dropdwon...
Looking forward for help
Thanks in Advance
7 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 28 Jan 2011, 01:12 PM
Hello Saravanan,
I am not quite sure about your requirement. If you want to hide the controls in EditItemTemplate based on the SelectedValue of DropDownList in RadWindow, try the following code snippet. Make necessary modification according to your requirement.
ASPX:
C#:
Thanks,
Princy.
I am not quite sure about your requirement. If you want to hide the controls in EditItemTemplate based on the SelectedValue of DropDownList in RadWindow, try the following code snippet. Make necessary modification according to your requirement.
ASPX:
<
telerik:RadWindow
ID
=
"RadWindow1"
runat
=
"server"
>
<
ContentTemplate
>
<
asp:DropDownList
ID
=
"DropDownList2"
runat
=
"server"
AutoPostBack
=
"true"
OnSelectedIndexChanged
=
"DropDownList2_SelectedIndexChanged"
>
<
asp:ListItem
Text
=
"Name"
Value
=
"Name"
></
asp:ListItem
>
<
asp:ListItem
Text
=
"Department"
Value
=
"Department"
></
asp:ListItem
>
</
asp:DropDownList
>
</
ContentTemplate
>
</
telerik:RadWindow
>
<
telerik:RadGrid
ID
=
"RadGrid1"
AutoGenerateColumns
=
"False"
runat
=
"server"
DataSourceID
=
"SqlDataSource1"
>
<
MasterTableView
CommandItemDisplay
=
"Top"
DataKeyNames
=
"EmployeeID"
>
<
Columns
>
<
telerik:GridTemplateColumn
>
<
EditItemTemplate
>
<
asp:TextBox
ID
=
"TextBox2"
runat
=
"server"
></
asp:TextBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridEditCommandColumn
>
</
telerik:GridEditCommandColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
C#:
protected
void
DropDownList2_SelectedIndexChanged(
object
sender, EventArgs e)
{
int
editIndex =Convert.ToInt32(RadGrid1.EditIndexes[0]);
GridEditFormItem edititem = (GridEditFormItem)RadGrid1.MasterTableView.GetItems(GridItemType.EditFormItem)[editIndex];
//accessing EditFormItem
TextBox txtbox = (TextBox)edititem.FindControl(
"TextBox2"
);
//access control in EditItemtemplate
if
(list.SelectedValue==
"Department"
)
txtbox.Visible =
false
;
}
Thanks,
Princy.
0

Saravanan
Top achievements
Rank 1
answered on 28 Jan 2011, 01:23 PM
Princy,
First of all Thanks for the solution... YOu are nearly there for my requirement...
My requirement is based on the dropdown ("DropDownList2") selected , I need to EditItemTemplate control (TextBox2) in Rad Content Window....Basically My dropdown will have which control of EditItemtemplate to display in RadContentWindow...
Thanks
First of all Thanks for the solution... YOu are nearly there for my requirement...
My requirement is based on the dropdown ("DropDownList2") selected , I need to EditItemTemplate control (TextBox2) in Rad Content Window....Basically My dropdown will have which control of EditItemtemplate to display in RadContentWindow...
Thanks
0

Princy
Top achievements
Rank 2
answered on 31 Jan 2011, 09:28 AM
Hello Saravanan,
One solution in you can place all the controls(DropDownList,TextBox) in ContentTemplate of RadWindow and initially make it visibility as 'false'. Then based on the selected value of DropDownList, change the visibility of controls accordingly.
Hope this helps,
Princy.
One solution in you can place all the controls(DropDownList,TextBox) in ContentTemplate of RadWindow and initially make it visibility as 'false'. Then based on the selected value of DropDownList, change the visibility of controls accordingly.
Hope this helps,
Princy.
0

Saravanan
Top achievements
Rank 1
answered on 31 Jan 2011, 09:48 AM
Is it possible to obtain the column name and cell content in Rowcontext menu?
Your help would be really appreciated...
Your help would be really appreciated...
0

Princy
Top achievements
Rank 2
answered on 01 Feb 2011, 09:54 AM
Hello Saravanan,
The following forum will help you to achieve this.
http://www.telerik.com/community/forums/aspnet-ajax/grid/how-to-find-column-values-of-a-selected-row-in-a-radgrid.aspx
Hope this helps,
Princy.
The following forum will help you to achieve this.
http://www.telerik.com/community/forums/aspnet-ajax/grid/how-to-find-column-values-of-a-selected-row-in-a-radgrid.aspx
Hope this helps,
Princy.
0

Saravanan
Top achievements
Rank 1
answered on 01 Feb 2011, 10:32 AM
Princy,
Thanks for the guidance, In my case I will not be knowing the column name, based on the right click I need to know on which column (uniquename) it happenned in client side / server side... Looking for help.. as we already lost 2 days in getting a solution...
Thanks for the guidance, In my case I will not be knowing the column name, based on the right click I need to know on which column (uniquename) it happenned in client side / server side... Looking for help.. as we already lost 2 days in getting a solution...
0

Princy
Top achievements
Rank 2
answered on 02 Feb 2011, 11:26 AM
Hello Saravanan,
Try the following approach to get the column name in RowContextmenu.
ASPX:
Java Script:
Thanks,
Princy.
Try the following approach to get the column name in RowContextmenu.
ASPX:
<
ClientSettings
>
<
ClientEvents
OnRowContextMenu
=
"RowContextMenu"
></
ClientEvents
>
</
ClientSettings
>
Java Script:
<script type=
"text/javascript"
>
function
RowContextMenu(sender, eventArgs) {
var
menu = $find(
"<%=RadMenu1.ClientID %>"
);
var
evt = eventArgs.get_domEvent();
var
index = eventArgs.get_itemIndexHierarchical();
var
masterTable = sender.get_masterTableView();
var
cellIndex = evt.target.cellIndex;
var
column = masterTable.get_columns()[cellIndex];
var
uniqueName = column.get_uniqueName();
alert(uniqueName); //getting column name
if
(evt.target.tagName ==
"INPUT"
|| evt.target.tagName ==
"A"
) {
return
;
}
document.getElementById(
"radGridClickedRowIndex"
).value = index;
sender.get_masterTableView().selectItem(sender.get_masterTableView().get_dataItems()[index].get_element(),
true
);
menu.show(evt);
evt.cancelBubble =
true
;
evt.returnValue =
false
;
if
(evt.stopPropagation) {
evt.stopPropagation();
evt.preventDefault();
}
}
</script>
Thanks,
Princy.