PDA

View Full Version : [CLOSED] SortChange event calling two times



shaileshsakaria
Nov 22, 2013, 12:17 PM
Hi!

I have written "SortChange" listener in grid, but it is calling two times while I click on any header cell of grid. How can I prevent it? Actually I want to sort it cusotom through code behind but its calling two times. I have also tried to apply "RemoteSort"="true" in store's property but it didn't help.




<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SortingIssue.aspx.cs" Inherits="ExtNetTest.Admin.SortingIssue" %>
<!DOCTYPE html>
<script runat="server">

protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.store1.DataSource = new object[]
{


new object[] {1,"1.0","Automatic","ABC XYZ","ABC ABC"},
new object[] {2,"1.0","Automatic","ABC PQR","PQR ABC"},
new object[] {3,"1.0","Automatic","QQQ AAA","AAA BBB"},
new object[] {4,"1.0","Automatic","QWE QWE","ASD ASD"},
new object[] {5,"1.0","Automatic","123123123 123123123","121212 121212"},
new object[] {6,"1.0","Automatic","123456789 12345","987654321 54321"},
new object[] {7,"1.0","Automatic","ZZZ CCC","AAA BBB"},
new object[] {8,"1.0","Automatic","EEE EEE","QWE QWE"},
new object[] {9,"1.0","Automatic","QQQ WWW RRR TTTT YYY UUU","QQQ WWW DDD FFF"},
new object[] {10,"1.0","Automatic","QQQQQ FFFF TTTTT YYYYY","QQQQQ FFFF TTTTT YYYYY"}
};

this.store1.DataBind();
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />

<ext:GridPanel
ID="grid1"
runat="server"
MultiSelect="true"
Flex="1"
Height="300"
ForceFit="true"
Anchor="100% 100%"
Margins="0 0 0 3"
RowLines="true"
ColumnLines="true"
IDMode="Static"

>
<Store>
<ext:Store ID="store1" runat="server">
<Model>
<ext:Model ID="Model1" runat="server" IDProperty="ID">
<Fields>
<ext:ModelField Name="ID"></ext:ModelField>
<ext:ModelField Name="Rank"></ext:ModelField>
<ext:ModelField Name="Calculate"></ext:ModelField>
<ext:ModelField Name="BeforRow"></ext:ModelField>
<ext:ModelField Name="AfterRow"></ext:ModelField>
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel >
<Columns>
<ext:NumberColumn ID="ColumnNumber" runat="server" Text="Rank" Hideable="false" DataIndex="Rank" Format="9.9" Width="50" MaxWidth="50" MinWidth="50" AnchorHorizontal="100" />
<ext:Column ID="Column17" runat="server" Text="Calculate" Hideable="false" DataIndex="Calculate" Width="80" MaxWidth="80" AnchorVertical="100" MinWidth="80"/>
<ext:Column ID="Column1" runat="server" Text="case" Flex="1" Hideable="false">
<Columns>


<ext:Column ID="Column13" runat="server" Text="Befor" MinWidth="450" Hideable="false" DataIndex="BeforRow">
</ext:Column>
<ext:Column ID="Column14" runat="server" Text="After" MinWidth="450" MaxWidth="5000" Hideable="false" DataIndex="AfterRow" >
</ext:Column>
</Columns>
</ext:Column>
</Columns>
</ColumnModel>
<Listeners>
<SortChange Handler="alert('Sorted!');" />
</Listeners>
</ext:GridPanel>

</form>
</body>
</html>



Thanks

Daniil
Nov 22, 2013, 3:17 PM
Hi @shaileshsakaria,

If you need remote sorting (i.e. sorting on server), when RemoteSort="true" is really a way to go.

You should configure a Store with a Proxy (PageProxy or AjaxProxy, for example). Here is an example with PageProxy.
http://examples2.ext.net/#/GridPanel/Paging_and_Sorting/DirectMethod/