I have the following code in place on a RadGrid. I need to be able to access the ddColumns dropdown HTML element from Javascript.and get the selected value from the dropdown list. Can anyone give me an example of how to do this?
<telerik:RadGrid ID="rgSchedules" Width="100%" CssClass="centergrid" runat="server" ShowFooter="true"
OnItemDataBound="rgNettingProductSchedules_ItemDataBound" OnDetailTableDataBind="rgNettingProductSchedules_DetailTableDataBind"
OnSortCommand="rgNettingProductSchedules_SortCommand" OnItemCommand="rgNettingProductSchedules_ItemCommand" AllowSorting="false"
SortingSettings-SortedBackColor="ControlDark" AllowFilteringByColumn="false" AllowPaging="false" AllowMultiRowSelection="true">
<%-- OnDataBound="rgSchedules_DataBound" --%>
<GroupingSettings CaseSensitive="false" />
<ClientSettings>
<ClientEvents OnHierarchyExpanded="RowExpanded" />
<Selecting AllowRowSelect="true" />
<Selecting EnableDragToSelectRows="false" />
</ClientSettings>
<MasterTableView Name="Scheduling" DataKeyNames="Id" AllowMultiColumnSorting="false" AllowNaturalSort="true" AllowPaging="false"
HierarchyLoadMode="Client" AllowFilteringByColumn="false" AutoGenerateColumns="false" CommandItemDisplay="Top" CommandItemStyle-Height="30px">
<CommandItemTemplate>
<table width="100%" >
<tr>
<td align="left" >
<%--<a href="javascript:void(0);" onclick="javascript:BeginIndexCollection();">--%>
<a href="javascript:void(0);" onclick="javascript:InitGroupEdit();">
<asp:Image ID="Image3" runat="server" style="padding: 0px 5px 0px 5px; border: none;" ImageUrl="~/_assets/images/Edit.gif" />
Group Schedule Edit
</a>
<a href="javascript:void(0);" onclick="javascript:BeginShiftIndexCollection();">
<asp:Image ID="Image4" runat="server" style="padding: 0px 5px 0px 5px; border: none;" ImageUrl="~/_assets/images/Edit.gif" />
Group Shift Edit
</a>
</td>
<td align="left">
<asp:Label ID="lblColumn" runat="server" style="color:White" Text="Show/Hide Columns"></asp:Label>
<asp:DropDownList ID="ddColumns" onchange="ShowHideColumn()" runat="server">
<asp:ListItem Selected="True" Value="SelectOne" Text="Select One" />
<asp:ListItem Value="Alloy" Text="Alloy" />
<asp:ListItem Value="PlannedCasts" Text="Planned Casts" />
<asp:ListItem Value="PlannedCastsLbs" Text="Planned Casts Lbs" />
<asp:ListItem Value="PlannedGoodLbs" Text="Planned Good Lbs" />
<asp:ListItem Value="ActualCast" Text="Actual Cast"/>
<asp:ListItem Value="ActualCastLbs" Text="Actual Cast Lbs" />
<asp:ListItem Value="ActualGoodLbs" Text="Actual Good Lbs" />
<asp:ListItem Value="Scenario" Text="Scenario" />
</asp:DropDownList>
</td>
</tr>
</table>
</CommandItemTemplate>
function ShowHideColumn() {
var radGrid = GetProductGrid();
var dd = document.getElementById("ddColumns");
alert(dd);
var table = radGrid.get_masterTableView();
var column = table.getColumnByUniqueName("Alloy");
if (column.style.display = "none")
column.style.display = "";
else
column.style.display = "none";
}
<telerik:RadGrid ID="rgSchedules" Width="100%" CssClass="centergrid" runat="server" ShowFooter="true"
OnItemDataBound="rgNettingProductSchedules_ItemDataBound" OnDetailTableDataBind="rgNettingProductSchedules_DetailTableDataBind"
OnSortCommand="rgNettingProductSchedules_SortCommand" OnItemCommand="rgNettingProductSchedules_ItemCommand" AllowSorting="false"
SortingSettings-SortedBackColor="ControlDark" AllowFilteringByColumn="false" AllowPaging="false" AllowMultiRowSelection="true">
<%-- OnDataBound="rgSchedules_DataBound" --%>
<GroupingSettings CaseSensitive="false" />
<ClientSettings>
<ClientEvents OnHierarchyExpanded="RowExpanded" />
<Selecting AllowRowSelect="true" />
<Selecting EnableDragToSelectRows="false" />
</ClientSettings>
<MasterTableView Name="Scheduling" DataKeyNames="Id" AllowMultiColumnSorting="false" AllowNaturalSort="true" AllowPaging="false"
HierarchyLoadMode="Client" AllowFilteringByColumn="false" AutoGenerateColumns="false" CommandItemDisplay="Top" CommandItemStyle-Height="30px">
<CommandItemTemplate>
<table width="100%" >
<tr>
<td align="left" >
<%--<a href="javascript:void(0);" onclick="javascript:BeginIndexCollection();">--%>
<a href="javascript:void(0);" onclick="javascript:InitGroupEdit();">
<asp:Image ID="Image3" runat="server" style="padding: 0px 5px 0px 5px; border: none;" ImageUrl="~/_assets/images/Edit.gif" />
Group Schedule Edit
</a>
<a href="javascript:void(0);" onclick="javascript:BeginShiftIndexCollection();">
<asp:Image ID="Image4" runat="server" style="padding: 0px 5px 0px 5px; border: none;" ImageUrl="~/_assets/images/Edit.gif" />
Group Shift Edit
</a>
</td>
<td align="left">
<asp:Label ID="lblColumn" runat="server" style="color:White" Text="Show/Hide Columns"></asp:Label>
<asp:DropDownList ID="ddColumns" onchange="ShowHideColumn()" runat="server">
<asp:ListItem Selected="True" Value="SelectOne" Text="Select One" />
<asp:ListItem Value="Alloy" Text="Alloy" />
<asp:ListItem Value="PlannedCasts" Text="Planned Casts" />
<asp:ListItem Value="PlannedCastsLbs" Text="Planned Casts Lbs" />
<asp:ListItem Value="PlannedGoodLbs" Text="Planned Good Lbs" />
<asp:ListItem Value="ActualCast" Text="Actual Cast"/>
<asp:ListItem Value="ActualCastLbs" Text="Actual Cast Lbs" />
<asp:ListItem Value="ActualGoodLbs" Text="Actual Good Lbs" />
<asp:ListItem Value="Scenario" Text="Scenario" />
</asp:DropDownList>
</td>
</tr>
</table>
</CommandItemTemplate>
function ShowHideColumn() {
var radGrid = GetProductGrid();
var dd = document.getElementById("ddColumns");
alert(dd);
var table = radGrid.get_masterTableView();
var column = table.getColumnByUniqueName("Alloy");
if (column.style.display = "none")
column.style.display = "";
else
column.style.display = "none";
}