or

| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head runat="server"> |
| <title></title> |
| <script type="text/javascript"> |
| function ColumnSwapped(sender, eventArgs) { |
| var cols = $find(RadGrid1_ClientId).get_masterTableView()._columnsInternal; |
| for (var idx = 0; idx < cols.length; idx++) { |
| alert("Column:" + idx + ", UniqueName:" + cols[idx]._data.UniqueName + ", DataField:" + cols[idx]._data.DataField); |
| } |
| } |
| </script> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <div> |
| <asp:ScriptManager ID="ScriptManager" runat="server" AsyncPostBackTimeout="1000" |
| ScriptMode="Release"> |
| </asp:ScriptManager> |
| <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True" |
| AllowMultiColumnSorting="False" AutoGenerateColumns="False" Width="100%" AllowMultiRowSelection="True" |
| Height="565px" PageSize="20" ShowStatusBar="True" BorderWidth="1px" GridLines="Vertical"> |
| <MasterTableView> |
| <Columns> |
| <telerik:GridBoundColumn DataField="NUMBERS" HeaderText="NUMBERS" UniqueName="NUMBERS"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="LETTERS" HeaderText="LETTERS" UniqueName="LETTERS"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="WORDS" HeaderText="WORDS" UniqueName="WORDS"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| </MasterTableView> |
| <ClientSettings AllowColumnsReorder="true" ColumnsReorderMethod="Reorder" ReorderColumnsOnClient="true"> |
| <ClientEvents OnColumnSwapped="ColumnSwapped" /> |
| <Scrolling AllowScroll="True" UseStaticHeaders="True" /> |
| <Resizing AllowColumnResize="true" /> |
| <Selecting AllowRowSelect="true" /> |
| <DataBinding Location="~/TestService.asmx" SelectMethod="GetData"> |
| </DataBinding> |
| </ClientSettings> |
| </telerik:RadGrid> |
| </div> |
| </form> |
| <script type="text/javascript"> |
| var RadGrid1_ClientId = "<%= RadGrid1.ClientID %>"; |
| </script> |
| </body> |
| </html> |
| [WebService(Namespace = "http://tempuri.org/")] |
| [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] |
| [ScriptService] |
| [System.ComponentModel.ToolboxItem(false)] |
| public class TestService : System.Web.Services.WebService { |
| [WebMethod(EnableSession = true)] |
| public Dictionary<string, object> GetData(int startRowIndex, int maximumRows, List<GridSortExpression> sortExpression, List<GridFilterExpression> filterExpression) { |
| Dictionary<string, object> data = new Dictionary<string, object>(); |
| List<object> rows = new List<object>(); |
| for (int i = 0; i < 100; i++) { |
| rows.Add(new { |
| NUMBERS = 1, |
| LETTERS = "A", |
| WORDS = "One" |
| }); |
| rows.Add(new { |
| NUMBERS = 2, |
| LETTERS = "B", |
| WORDS = "Two" |
| }); |
| rows.Add(new { |
| NUMBERS = 3, |
| LETTERS = "C", |
| WORDS = "Three" |
| }); |
| rows.Add(new { |
| NUMBERS = 4, |
| LETTERS = "D", |
| WORDS = "Four" |
| }); |
| rows.Add(new { |
| NUMBERS = 5, |
| LETTERS = "E", |
| WORDS = "Five" |
| }); |
| rows.Add(new { |
| NUMBERS = 6, |
| LETTERS = "F", |
| WORDS = "Six" |
| }); |
| } |
| data.Add("Count", rows.Count); |
| int numElements = maximumRows; |
| if (maximumRows > (rows.Count - startRowIndex)) { |
| maximumRows = rows.Count - startRowIndex; |
| } |
| var tmpData = rows.GetRange(startRowIndex, maximumRows); |
| data.Add("Data", tmpData); |
| return data; |
| } |
| } |
I am in the process of upgrading an older application that used the previous RADControls to use the ASP.NET AJAX Controls. I have a grid with 4 columns (many rows) and each column is a link button. When a link button is clicked i want to filter that column by whatever text the link button has. (many rows will have the same values). here is my old code for the ASP.NET controls and it worked fine:
here is one of my snippets from the RadGrid1_ItemCommand event (Fields/Columns changed for easy read):
| if (e.CommandName = "FilterCol1") { GridDataItem item = (GridDataItem)e.Item; |
| LinkButton lb = (LinkButton)item["Col1"].FindControl("btnCol1"); |
| string strFilter = lb.Text; |
| rgBOM.MasterTableView.FilterExpression = "([COL1_DATAFIELD] LIKE \'" + strFilter + "%\') "; |
| GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("Col1"); |
| column.CurrentFilterFunction = GridKnownFunction.Contains; |
| RadGrid1.Rebind(); } |