Hello,
I have a grid that has both GridBoundColumns and GridButtonColumns and is populated using client-side databinding.
On Page_Load, I hide one of the GridButtonColumns using the following code:
C#:
Here is what the grid looks like on initial load: grid on initial load
When the user clicks a radio button, I need to show or hide certain columns depending on their selection. I attempt to do this using the following code:
JS:
This successfully hides the two GridBoundColumns (CustomerImported and RollsReceived) but the two GridButtonColumns (ViewReceiptErrors and ViewTransactionHistory) do not get hidden. Also, the GridButtonColumn (ViewErrorDescription) that I'm trying to show does not get displayed. Here is what the grid looks like after this code is executed: grid after trying to show/hide columns
Could someone tell me what I'm doing wrong?
Here is the markup for the grid:
Thanks,
Marie
I have a grid that has both GridBoundColumns and GridButtonColumns and is populated using client-side databinding.
On Page_Load, I hide one of the GridButtonColumns using the following code:
C#:
| grdManifest.MasterTableView.GetColumn("ViewErrorDescription").Display = false; |
When the user clicks a radio button, I need to show or hide certain columns depending on their selection. I attempt to do this using the following code:
JS:
| tableView = grdManifest.get_masterTableView(); |
| tableView.showColumn(tableView.getColumnByUniqueName("ViewErrorDescription").get_element().cellIndex); |
| tableView.hideColumn(tableView.getColumnByUniqueName("CustomerImported").get_element().cellIndex); |
| tableView.hideColumn(tableView.getColumnByUniqueName("RollsReceived").get_element().cellIndex); |
| tableView.hideColumn(tableView.getColumnByUniqueName("ViewReceiptErrors").get_element().cellIndex); |
| tableView.hideColumn(tableView.getColumnByUniqueName("ViewTransactionHistory").get_element().cellIndex); |
Could someone tell me what I'm doing wrong?
Here is the markup for the grid:
| <telerik:RadGrid ID="grdManifest" runat="server" AllowFilteringByColumn="false" AllowSorting="true" |
| AllowPaging="true" PageSize="13" EnableViewState="false" AutoGenerateColumns="false" |
| style="display:none; overflow:hidden;"> |
| <MasterTableView ClientDataKeyNames="ManifestID, SupplierCode, SoldToCodeType, SoldToCode, CorporateCode, PrintSiteCode" |
| ShowHeader="true"> |
| <Columns> |
| <telerik:GridBoundColumn DataField="ManifestID" Visible="false" DataType="System.Int32" |
| UniqueName="ManifestID" /> |
| <telerik:GridBoundColumn DataField="ManifestNumber" HeaderText="Manifest Number" |
| DataType="System.String" DataFormatString="<nobr>{0}</nobr>" HeaderStyle-Width="95px" |
| ItemStyle-Width="95px" /> |
| <telerik:GridBoundColumn DataField="BillOfLading" HeaderText="BOL" DataType="System.String" |
| DataFormatString="<nobr>{0}</nobr>" UniqueName="BillOfLading" HeaderStyle-Width="90px" |
| ItemStyle-Width="90px" /> |
| <telerik:GridBoundColumn DataField="SupplierCode" Visible="false" DataType="System.String" /> |
| <telerik:GridBoundColumn DataField="SoldToCodeType" Visible="false" DataType="System.String" /> |
| <telerik:GridBoundColumn DataField="SoldToCode" Visible="false" DataType="System.String" /> |
| <telerik:GridButtonColumn HeaderText="Sold To" ButtonType="LinkButton" CommandName="ViewSoldTo" |
| DataTextField="SoldTo" DataTextFormatString="<nobr>{0}</nobr>" UniqueName="ViewSoldTo" |
| HeaderStyle-Width="150px" ItemStyle-Width="150px" SortExpression="SoldTo"> |
| </telerik:GridButtonColumn> |
| <telerik:GridBoundColumn DataField="CorporateCode" Visible="false" DataType="System.String" /> |
| <telerik:GridBoundColumn DataField="PrintSiteCode" Visible="false" DataType="System.String" /> |
| <telerik:GridButtonColumn HeaderText="Print Site" ButtonType="LinkButton" CommandName="ViewPrintSite" |
| DataTextField="PSName" DataTextFormatString="<nobr>{0}</nobr>" UniqueName="ViewPrintSite" |
| HeaderStyle-Width="150px" ItemStyle-Width="150px" SortExpression="PrintSite"> |
| </telerik:GridButtonColumn> |
| <telerik:GridBoundColumn DataField="ShipDate" HeaderText="Ship Date" DataType="System.DateTime" |
| DataFormatString="{0:MM/dd/yyyy}" UniqueName="ShipDate" HeaderStyle-Width="70px" |
| ItemStyle-Width="70px" /> |
| <telerik:GridBoundColumn DataField="ImportDate" HeaderText="Import Date" DataType="System.DateTime" |
| DataFormatString="{0:MM/dd/yyyy}" HeaderStyle-Width="70px" ItemStyle-Width="70px" /> |
| <telerik:GridBoundColumn DataField="MessageType" HeaderText="Message Type" DataType="System.String" |
| HeaderStyle-Width="60px" ItemStyle-Width="60px" /> |
| <telerik:GridButtonColumn HeaderText="Total Items" ButtonType="LinkButton" CommandName="ViewItems" |
| DataTextField="TotalItems" DataTextFormatString="{0}" UniqueName="ViewItems" |
| HeaderStyle-Width="30px" ItemStyle-Width="30px" SortExpression="TotalItems"> |
| </telerik:GridButtonColumn> |
| <telerik:GridButtonColumn HeaderText="Total Rolls" ButtonType="LinkButton" CommandName="ViewRolls" |
| DataTextField="TotalRolls" DataTextFormatString="{0}" UniqueName="ViewRolls" |
| HeaderStyle-Width="30px" ItemStyle-Width="30px" SortExpression="TotalRolls"> |
| </telerik:GridButtonColumn> |
| <telerik:GridBoundColumn DataField="TotalGrossWeight" HeaderText="Total Gross Weight" |
| DataType="System.Decimal" DataFormatString="{0:N}" HeaderStyle-Width="75px" ItemStyle-Width="75px" /> |
| <telerik:GridBoundColumn DataField="CustomerImported" HeaderText="Customer Imported" |
| DataType="System.String" HeaderStyle-Width="70px" ItemStyle-Width="70px" UniqueName="CustomerImported"/> |
| <telerik:GridBoundColumn DataField="RollsReceived" HeaderText="Rolls Received" DataType="System.Int32" |
| HeaderStyle-Width="55px" ItemStyle-Width="55px" /> |
| <telerik:GridButtonColumn HeaderText="Receipt Errors" ButtonType="LinkButton" CommandName="ViewReceiptErrors" |
| DataTextField="ReceiptErrors" DataTextFormatString="<nobr>{0}</nobr>" UniqueName="ViewReceiptErrors" |
| HeaderStyle-Width="90px" ItemStyle-Width="90px" SortExpression="ReceiptErrors"> |
| </telerik:GridButtonColumn> |
| <telerik:GridButtonColumn HeaderText="Transaction History" ButtonType="LinkButton" |
| CommandName="ViewTransactionHistory" DataTextFormatString="<nobr>View Transactions</nobr>" |
| UniqueName="ViewTransactionHistory" DataTextField="ManifestID" HeaderStyle-Width="110px" |
| ItemStyle-Width="110px"> |
| </telerik:GridButtonColumn> |
| <telerik:GridButtonColumn HeaderText="Error Description" ButtonType="LinkButton" |
| CommandName="ViewErrorDescription" DataTextField="ReceiptErrors" |
| DataTextFormatString="<nobr>{0}</nobr>" UniqueName="ViewErrorDescription" |
| SortExpression="ReceiptErrors" HeaderStyle-Width="110px" |
| ItemStyle-Width="110px"> |
| </telerik:GridButtonColumn> |
| </Columns> |
| <PagerStyle Mode="Slider" /> |
| </MasterTableView> |
| <ClientSettings AllowColumnHide="true"> |
| <ClientEvents OnCommand="grdManifest_OnCommand" |
| OnRowMouseOver="grdManifest_RowMouseOver" |
| OnRowContextMenu="grdManifest_RowContextMenu"/> |
| <Selecting AllowRowSelect="true" /> |
| <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="330px" /> |
| </ClientSettings> |
| </telerik:RadGrid> |
Thanks,
Marie