This is a migrated thread and some comments may be shown as answers.

[Solved] Persisting Column visbility/filtering/group by etc.

1 Answer 116 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Patrick Watts
Top achievements
Rank 1
Patrick Watts asked on 10 Jul 2009, 08:17 AM
Hi,

I  have followed the article below

http://www.telerik.com/community/code-library/aspnet-ajax/grid/storing-multiple-grid-settings-in-database-via-profile.aspx

I have everything working apart from the persistance of the visibility of the columns.
After extensive de-bugging and attempting other things by biggest problem is that the header context menu does not post-back for any of the column visbility settings, only the sorting / filtering / group by. Without the post-back, the render method does not get called and the settings are not saved.

I have included my RadGrid aspx code.

 

<telerik:RadGrid AutoGenerateColumns="false" DataSourceID="sqlTradeList" AllowFilteringByColumn="true"

 

 

ID="RadGrid1" runat="server" AllowPaging="true" ShowGroupPanel="true" AllowSorting="true"

 

 

EnableViewState="false" Width="80%">

 

 

<PagerStyle Mode="NextPrevAndNumeric" />

 

 

<MasterTableView TableLayout="Auto" EnableHeaderContextMenu="true">

 

 

<Columns>

 

 

<telerik:GridHyperLinkColumn HeaderText="TradeId" DataTextField="TradeId" SortExpression="TradeId"

 

 

DataNavigateUrlFormatString="~/Trade/PackageDetails.aspx?InternalPackageId={0}&PackageId={1}"

 

 

DataNavigateUrlFields="InternalPackageId,PackageId" />

 

 

<telerik:GridDateTimeColumn HeaderText="Trade Date" DataField="TradeDate" DataFormatString="{0:dd/MM/yyyy}"

 

 

SortExpression="TradeDate" />

 

 

<telerik:GridBoundColumn HeaderText="Source System" DataField="SourceSystemName"

 

 

SortExpression="SourceSystemName" />

 

 

<telerik:GridBoundColumn HeaderText="Asset Class" DataField="AssetClass" SortExpression="AssetClass" />

 

 

<telerik:GridBoundColumn HeaderText="Product" DataField="ProductName" SortExpression="ProductName" />

 

 

<telerik:GridBoundColumn HeaderText="Trader" DataField="TraderName" SortExpression="TraderName" />

 

 

<telerik:GridDateTimeColumn HeaderText="Last Updated" DataField="LastUpdated" DataFormatString="{0:dd/MM/yyyy mm:hh:ss}"

 

 

SortExpression="LastUpdated" />

 

 

<telerik:GridBoundColumn HeaderText="Version" DataField="TradeVersion" SortExpression="TradeVersion" />

 

 

</Columns>

 

 

</MasterTableView>

 

 

<HeaderContextMenu >

 

 

</HeaderContextMenu>

 

 

<ClientSettings AllowColumnsReorder="true" AllowColumnHide="true">

 

 

<ClientEvents />

 

 

</ClientSettings>

 

 

<GroupingSettings ShowUnGroupButton="true" />

 

 

</telerik:RadGrid>

 


Please can someone have a look and let me know where I am going wrong...

Cheers,

Paddy Watts

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 14 Jul 2009, 04:34 PM
Hello Patrick,

I have already answered to the support thread open on the same matter. Here is a quote of the answer:

Hello Patrick,

Thank you for contacting us.

In order to achieve your goal I will suggest you wire the OnColumnHidden and OnColumnShown clients event in order to understand  whether a client hide or show a column. Thus you can get the name of the shown/hidden column and make an ajaxRequest to the server and save add the name of the column to the collection of the hidden columns, for instance.

Here is a code snippet showing how to get the column name and perform Ajax request:
        <script type="text/javascript"
            function ColumnHidden(sender, args) { 
                debugger
                var columnName = args.get_gridColumn().get_uniqueName(); 
                $find("<%=RadAjaxManager1.ClientID %>").ajax_request("ColumnHidden|"+columnName); 
            } 
 
            function ColumnShown(sender, args) { 
                var columnName = args.get_gridColumn().get_uniqueName(); 
                $find("<%=RadAjaxManager1.ClientID %>").ajax_request("ColumnShown|" + columnName); 
            } 
        </script> 

Let me know if I can assist you further.

Best wishes,
Georgi Krustev
the Telerik team


I will ask you to continue our conversation in the support thread in order to avoid any duplication.

All the best,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Patrick Watts
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or