PDA

View Full Version : [CLOSED] Custom sort on some of the grid columns



Sowjanya
Apr 24, 2014, 5:11 AM
Hi,

I would like to implement the custom sort functionality on two of the columns in a grid(EXPECTED_MAX_DATE and EXPECTED_DB_MAX_DATE). I need custom sort on these grid columns because each of the columns , though its datatype is string, it has date values (bound as string to the model) and some other text values.

So, what i would like to implement is when i sort in ascending, the dates have to appear in ascending order first ( may be the dates have to be converted to date datatype so as to do sorting...) , and then the text in ascending order.
And when i do sort in descending, dates in descending order and then the text in descending order.

It would be great if a solution is known asap.

here is the code:
---------------------



<ext:GridPanel ID="InstanceTable" runat="server" Frame="true" Title="Instances" ForceFit="true" AutoScroll="true" Flex="1" >

<Store>



<ext:Store ID="InstanceTableStore" runat="server" AutoLoad="true" OnSubmitData="ExportToExcel" >
<Proxy>
<ext:AjaxProxy Json="true" Url='<%#MainGridStoreURL%>' AutoDataBind="true" >
<ActionMethods Read="POST" Create="POST" />
<Headers>
<ext:Parameter Name="Accept" Value="application/json" />
<ext:Parameter Name="Content-Type" Value="application/json" />
</Headers>
<ExtraParams>
<ext:StoreParameter Name="DaysBack" Value="90"/>
<ext:StoreParameter Name="CompType" Value="Sybase ASE"/>
<ext:StoreParameter Name="AlertType" Value=""/>
</ExtraParams>
<Writer>
<ext:JsonWriter Root="" Encode="true" />
</Writer>
<Reader>
<ext:JsonReader Root="" />
</Reader>
</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model ID="Model11" runat="server">
<Fields>
<ext:ModelField Name="PARENT_COMPONENT_ID" Type="Int" />
<ext:ModelField Name="COMPONENT_ID" Type="Int" />

<ext:ModelField Name="METRIC_NAME" Type="String" />
<ext:ModelField Name="ENVIRONMENT" Type="String" />
<ext:ModelField Name="COMPONENT_NAME" Type="String" />
<ext:ModelField Name="UNIT" Type="String" />
<ext:ModelField Name="PERC_USED" Type="Float" />
<ext:ModelField Name="PERC_AGR_USED" Type="Float" />
<ext:ModelField Name="PERC_AGR_FREE" Type="Float" />
<ext:ModelField Name="PERC_DEV_FREE" Type="Float" />
<ext:ModelField Name="PERC_GROWTH" Type="Float" />
<ext:ModelField Name="CAPACITY" Type="Float" />
<ext:ModelField Name="USED" Type="Float" />
<ext:ModelField Name="FREE" Type="Float" />
<ext:ModelField Name="EXPECTED_MAX_DATE" Type="String" >

</ext:ModelField>
<ext:ModelField Name="EXPECTED_DB_MAX_DATE" Type="String" >

</ext:ModelField>
<ext:ModelField Name="PEAK" Type="Float" />
<ext:ModelField Name="PEAK_DATE" Type="String">


</ext:ModelField>
<ext:ModelField Name="LAST_WEEK_PEAK" Type="Float" />
<ext:ModelField Name="LAST_7_DAY_INCR" Type="Float" />
<ext:ModelField Name="CAPACITY_NEED_6_MON" Type="Float" />
<ext:ModelField Name="USED_1_MON" Type="Float" />
<ext:ModelField Name="USED_6_MON" Type="Float" />
<ext:ModelField Name="LAST_UPDATED" Type="String" >

</ext:ModelField>
<ext:ModelField Name="WEEKS_OF_DATA" Type="Int" />

</Fields>
</ext:Model>
</Model>
<Listeners>
<BeforeLoad Handler="App.btnExportInstances.disable();" />
<Load Fn="getDistinctforColumnsInsGrid"/>


</Listeners>

</ext:Store>

</Store>
<Plugins>
<ext:BufferedRenderer ID="BufferedRenderer1" runat="server" />
</Plugins>

<ColumnModel ID="InstanceBase" runat="server" >

<Columns>

<ext:Column ID="Column1" runat="server" Width="150">


<Commands>
<ext:ImageCommand Icon="ApplicationGet" CommandName="ViewDetailsDB" Text="Details " />





<ext:ImageCommand Icon="ChartCurve" CommandName="ViewGraph" ToolTip-Text="View Graph" />
</Commands>
<Listeners>
<Command Handler="App.direct.ShowDetails(command,record.get('COMPONE NT_ID'),record.get('COMPONENT_NAME'));"/>


</Listeners>


</ext:Column>

<ext:Column ID="Column36" runat="server" Text="Environment" DataIndex="ENVIRONMENT" Width="120" Selectable="true" Align="Center"
>
<HeaderItems>
<ext:ComboBox
ID="cboEnvt"
runat="server"
Icon="Magnifier"
TriggerAction="All"
QueryMode="Local"
DisplayField="ENVIRONMENT"
ValueField="ENVIRONMENT">


<Listeners>
<Change Handler="applyFilter();" Buffer="250" />
</Listeners>
<Plugins>
<ext:ClearButton ID="ClearButton2" runat="server" />
</Plugins>
</ext:ComboBox>

</HeaderItems>
</ext:Column>

<ext:Column ID="Column3" runat="server" Text="Component Name" DataIndex="COMPONENT_NAME" Width="215" Selectable="true" Align="Center"
>
<HeaderItems>
<ext:TextField
ID="txtCompName"
runat="server"
Icon="Magnifier"
>

<Listeners>
<Change Handler="applyFilter();" Buffer="250" />
</Listeners>
<Plugins>
<ext:ClearButton ID="ClearButton1" runat="server" />
</Plugins>
</ext:TextField>

</HeaderItems>
</ext:Column>
<ext:Column ID="Column7" runat="server" Text="Metric Name" DataIndex="METRIC_NAME" Width="120" Align="Center"
>
<HeaderItems>
<ext:ComboBox
ID="cboMetricName"
runat="server"
Icon="Magnifier"
TriggerAction="All"
QueryMode="Local"
DisplayField="METRIC_NAME"
ValueField="METRIC_NAME">

<Listeners>
<Change Handler="applyFilter();" Buffer="250" />
</Listeners>

</ext:ComboBox>

</HeaderItems>

</ext:Column>





<ext:Column runat="server" Text="% space" Align="Center" Width="500" DataIndex="PERC_USED">
<Renderer Fn="renderSpaceRag" />

</ext:Column>
<ext:Column ID="Column9" runat="server" Text="Capacity<br>(GB)" DataIndex="CAPACITY" Align="Center" Width="100"
/>
<ext:Column ID="Column10" runat="server" Text="Used<br>(GB)" DataIndex="USED" Align="Center" Width="100"
/>
<ext:Column ID="Column11" runat="server" Text="Free<br>(GB)" DataIndex="FREE" Width="100" Align="Center"
/>
<ext:Column ID="Column12" runat="server" Text="Expected DataServer<br>Max Date" DataIndex="EXPECTED_MAX_DATE" Width="200" Align="Center"
>

<Renderer Fn="RenderColor" />

<HeaderItems>

<ext:DateField ID="dtFilter" runat="server" Editable="false">
<Listeners>
<Change Handler="applyFilter();" Buffer="250" />
</Listeners>
<Plugins>
<ext:ClearButton ID="ClearButton3" runat="server" />
</Plugins>
</ext:DateField>



</HeaderItems>

</ext:Column>


<ext:Column ID="Column37" runat="server" Text="Expected DataBase<br>Max Date" DataIndex="EXPECTED_DB_MAX_DATE" Width="200" Align="Center"
>

<Renderer Fn="RenderColor" />

<HeaderItems>

<ext:DateField ID="dtFilter2" runat="server" Editable="false">
<Listeners>
<Change Handler="applyFilter();" Buffer="250" />
</Listeners>
<Plugins>
<ext:ClearButton ID="ClearButton6" runat="server" />
</Plugins>
</ext:DateField>



</HeaderItems>

</ext:Column>

<ext:Column ID="Column17" runat="server" Text="% Growth<br>Rate" DataIndex="PERC_GROWTH" Width="100" Align="Center">

<Renderer Handler="return Ext.String.format(record.get('PERC_GROWTH') != 0 ?record.get('PERC_GROWTH').toFixed(2)+'%' : '0 %') "/>


</ext:Column>



<ext:Column ID="Column15" runat="server" Text="Peak<br>(GB)" DataIndex="PEAK" Width="90" Align="Center"
/>
<ext:Column ID="Column25" runat="server" Text="Last Week<br>Peak<br>(GB)" DataIndex="LAST_WEEK_PEAK" Width="100" Align="Center"
/>



<ext:Column ID="Column16" runat="server" Text="Date of<br>Peak" DataIndex="PEAK_DATE" Width="90" Align="Center"
>
<Renderer Fn="TrimText" />
</ext:Column>
<ext:Column ID="Column18" runat="server" Text="Last 7 Days<br>Increase<br>(GB)" DataIndex="LAST_7_DAY_INCR" Width="120" Align="Center"
/>
<ext:Column ID="Column21" runat="server" Text="Capacity Needed<br>for 6 Months<br>(GB)" DataIndex="CAPACITY_NEED_6_MON" Width="160" Align="Center"
>
<Renderer Handler="return Ext.String.format(record.get('CAPACITY_NEED_6_MON' ).toFixed(2)) "/>
</ext:Column>

<ext:Column ID="Column2" runat="server" Text="Used in<br>1 Month<br>(GB)" DataIndex="USED_1_MON" Width="120" Align="Center"
/>

<ext:Column ID="Column70" runat="server" Text="Used in<br>6 Months<br>(GB)" DataIndex="USED_6_MON" Width="110" Align="Center"
/>

<ext:Column ID="Column14" runat="server" Text="# Weeks Of<br>Data" DataIndex="WEEKS_OF_DATA" Width="120" Align="Center"
/>

<ext:Column ID="Column13" runat="server" Text="Last Updated" DataIndex="LAST_UPDATED" Width="140" Align="Center"
>
<Renderer Fn="TrimText" /></ext:Column>




</Columns>
</ColumnModel>

<SelectionModel>

<ext:RowSelectionModel ID="CellSelectionModel2" runat="server" EnableTextSelection="true" >
<DirectEvents>

</DirectEvents>
</ext:RowSelectionModel>
</SelectionModel>
<View>
<ext:GridView ID="GridView3" runat="server" EnableTextSelection ="true">

</ext:GridView>
</View>

</ext:GridPanel>



Thanks,
Veda

geoffrey.mcgill
Apr 24, 2014, 5:22 AM
Please remove everything from your code sample that is not directly related to the problem. Are all those Columns, ModelFields, SelectionModel, extra Parameters required?

geoffrey.mcgill
Apr 24, 2014, 5:25 AM
It would be great if a solution is known asap.

Please item #4 at the following location:

http://forums.ext.net/showthread.php?10205-More-Information-Required

While you're in there, please review read the rest of that thread, as well as the following guidelines before posting in the forums again.

http://forums.ext.net/showthread.php?3440-Forum-Guidelines-For-Posting-New-Topics

Sowjanya
Apr 24, 2014, 3:27 PM
Hi,

Yes...I thought it would be better to provide the entire model / columns ... anyways, here is the updated code:



<ext:GridPanel ID="InstanceTable" runat="server" Frame="true" Title="Instances" ForceFit="true" AutoScroll="true" Flex="1" >

<Store>



<ext:Store ID="InstanceTableStore" runat="server" AutoLoad="true" OnSubmitData="ExportToExcel" >
<Proxy>
<ext:AjaxProxy Json="true" Url='<%#MainGridStoreURL%>' AutoDataBind="true" >
<ActionMethods Read="POST" Create="POST" />
<Headers>
<ext:Parameter Name="Accept" Value="application/json" />
<ext:Parameter Name="Content-Type" Value="application/json" />
</Headers>
<ExtraParams>
<ext:StoreParameter Name="DaysBack" Value="90"/>
<ext:StoreParameter Name="CompType" Value="Sybase ASE"/>
<ext:StoreParameter Name="AlertType" Value=""/>
</ExtraParams>
<Writer>
<ext:JsonWriter Root="" Encode="true" />
</Writer>
<Reader>
<ext:JsonReader Root="" />
</Reader>
</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model ID="Model11" runat="server">
<Fields>
/>
<ext:ModelField Name="COMPONENT_ID" Type="Int" />

<ext:ModelField Name="METRIC_NAME_ID" Type="String" />

<ext:ModelField Name="EXPECTED_MAX_DATE" Type="String" >

</ext:ModelField>
<ext:ModelField Name="EXPECTED_DB_MAX_DATE" Type="String" >
</ext:ModelField>

</Fields>
</ext:Model>
</Model>
<Listeners>
<BeforeLoad Handler="App.btnExportInstances.disable();" />
<Load Fn="getDistinctforColumnsInsGrid"/>
</Listeners>

</ext:Store>

</Store>
<Plugins>
<ext:BufferedRenderer ID="BufferedRenderer1" runat="server" />
</Plugins>

<ColumnModel ID="InstanceBase" runat="server" >

<Columns>

<ext:Column ID="Column7" runat="server" Text="Metric Name" DataIndex="METRIC_NAME" Width="120" Align="Center"
>

</ext:Column>

/>
<ext:Column ID="Column12" runat="server" Text="Expected DataServer<br>Max Date" DataIndex="EXPECTED_MAX_DATE" Width="200" Align="Center"
>





</ext:Column>


<ext:Column ID="Column37" runat="server" Text="Expected DataBase<br>Max Date" DataIndex="EXPECTED_DB_MAX_DATE" Width="200" Align="Center"
>

</ext:Column>

</Columns>
</ColumnModel>


<View>
<ext:GridView ID="GridView3" runat="server" EnableTextSelection ="true">

</ext:GridView>
</View>

</ext:GridPanel>

geoffrey.mcgill
Apr 24, 2014, 3:40 PM
Please remove all code that is not directly related to the problem. As well, when I try to run your sample, exceptions are thrown.

Sowjanya
Apr 24, 2014, 4:24 PM
Please remove all code that is not directly related to the problem. As well, when I try to run your sample, exceptions are thrown.

Hey,

Sorry ! i know this is really messy ! :(

I think i removed all the listeners and now it should be okay !




ext:GridPanel ID="InstanceTable" runat="server" Frame="true" Title="Instances" ForceFit="true" AutoScroll="true" Flex="1" >

<Store>



<ext:Store ID="InstanceTableStore" runat="server" AutoLoad="true" >
<Proxy>
<ext:AjaxProxy Json="true" Url='<%#MainGridStoreURL%>' AutoDataBind="true" >
<ActionMethods Read="POST" Create="POST" />
<Headers>
<ext:Parameter Name="Accept" Value="application/json" />
<ext:Parameter Name="Content-Type" Value="application/json" />
</Headers>
<ExtraParams>
<ext:StoreParameter Name="DaysBack" Value="90"/>
<ext:StoreParameter Name="CompType" Value="Sybase"/>
<ext:StoreParameter Name="AlertType" Value=""/>
</ExtraParams>
<Writer>
<ext:JsonWriter Root="" Encode="true" />
</Writer>
<Reader>
<ext:JsonReader Root="" />
</Reader>
</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model ID="Model11" runat="server">
<Fields>
/>
<ext:ModelField Name="COMPONENT_ID" Type="Int" />

<ext:ModelField Name="METRIC_NAME" Type="String" />

<ext:ModelField Name="EXPECTED_MAX_DATE" Type="String" >

</ext:ModelField>
<ext:ModelField Name="EXPECTED_DB_MAX_DATE" Type="String" >
</ext:ModelField>

</Fields>
</ext:Model>
</Model>
</ext:Store>

</Store>
<Plugins>
<ext:BufferedRenderer ID="BufferedRenderer1" runat="server" />
</Plugins>

<ColumnModel ID="InstanceBase" runat="server" >

<Columns>

<ext:Column ID="Column7" runat="server" Text="Metric Name" DataIndex="METRIC_NAME" Width="120" Align="Center"
>

</ext:Column>

/>
<ext:Column ID="Column12" runat="server" Text="Expected DataServer<br>Max Date" DataIndex="EXPECTED_MAX_DATE" Width="200" Align="Center"
>





</ext:Column>


<ext:Column ID="Column37" runat="server" Text="Expected DataBase<br>Max Date" DataIndex="EXPECTED_DB_MAX_DATE" Width="200" Align="Center"
>

</ext:Column>

</Columns>
</ColumnModel>


<View>
<ext:GridView ID="GridView3" runat="server" EnableTextSelection ="true">

</ext:GridView>
</View>

</ext:GridPanel>

geoffrey.mcgill
Apr 24, 2014, 5:03 PM
Sorry ! i know this is really messy ! :(

So is there any particular reason why you cannot clean up your code samples? How about removing unnecessary white-space?

Are the following configurations required to reproduce the problem:


AjaxProxy > Headers > Parameter
AjaxProxy > Writer > JsonWriter
AjaxProxy > StoreParameter
Plugins > BufferedRenderer
View > GridView

Sowjanya
Apr 24, 2014, 5:56 PM
Hey,

Yes, coz i thought of letting know that i am using ajaxproxy and so i had it in the code.
Also, since I did not see any issues caused by having just bufferedrenderer and gridview in the code , I had them in the code.

ok, still if that is not what is needed, I will remove them too..

here is the updated code:
-----------------------------





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.Store1.DataSource = new object []
{
new object[] { 71, "name1", "Jan 23, 2014", "Apr 23, 2014" },
new object[] { 29, "name12", "Feb 23, 2014", "May 04, 2014" },

new object[] { 61, "name13", "<=0 growth", "<=0 growth" },
new object[] { 63, "name14", "abcd", "<=0 growth" },
new object[] { 35, "name15", "bye","hi123" },
new object[] { 45, "name16", "Oct 04 2014" ,"May 13, 2014" }
};

this.Store1.DataBind();
}
}
</script>
</title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager runat="server"/>




<ext:GridPanel ID="InstanceTable" runat="server" Frame="true" Title="Instances" ForceFit="true" AutoScroll="true" Flex="1">

<Store>
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model ID="Model11" runat="server">
<Fields>

<ext:ModelField Name="COMPONENT_ID" Type="Int" />

<ext:ModelField Name="METRIC_NAME " Type="String" />

<ext:ModelField Name="EXPECTED_MAX_DATE" Type="String" >

</ext:ModelField>
<ext:ModelField Name="EXPECTED_DB_MAX_DATE" Type="String" >
</ext:ModelField>

</Fields>
</ext:Model>
</Model>
</ext:Store>

</Store>

<ColumnModel ID="InstanceBase" runat="server" >

<Columns>

<ext:Column ID="Column7" runat="server" Text="Metric Name" DataIndex="METRIC_NAME" Width="120" Align="Center"
>

</ext:Column>


<ext:Column ID="Column12" runat="server" Text="Expected DataServer<br>Max Date" DataIndex="EXPECTED_MAX_DATE" Width="200" Align="Center"
>





</ext:Column>


<ext:Column ID="Column37" runat="server" Text="Expected DataBase<br>Max Date" DataIndex="EXPECTED_DB_MAX_DATE" Width="200" Align="Center"
>

</ext:Column>

</Columns>
</ColumnModel>

</ext:GridPanel>

geoffrey.mcgill
Apr 24, 2014, 7:22 PM
ok, still if that is not what is needed, I will remove them too..

I asked several times to remove all code that is not directly related to the problem. We ask everyone to spend a few minutes simplifying their code sample down to the minimum required to reproduce the problem, and ensure it's runnable.

You have a history of dumping your code into these forums and we end up spending our time trying to piece together some kind of sample that's testable. This process wastes our time and yours. Our job is to not sit around formatting and editing your code.

We've pointed you several times to the forum Guidelines. Following the tips provided in these guidelines will ensure you get the quickest and most accurate response from the support team. I will provide the links again:

http://forums.ext.net/showthread.php?3440-Forum-Guidelines-For-Posting-New-Topics

http://forums.ext.net/showthread.php?10205-More-Information-Required

Now, the last sample you provided is still throwing exceptions, but it looks like it's getting closer to working. I will spend some of my time formatting and editing your code sample to get it to a runnable state, then post the updated sample for your review. From there we should be able to finally offer some suggestions.

geoffrey.mcgill
Apr 24, 2014, 7:39 PM
I have simplified your sample. It appears to still reproduce the sorting issue you described in your first post. Can you confirm?

Example


<%@ Page Language="C#" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.Store1.DataSource = new object []
{
new object[] { "Jan 23, 2014" },
new object[] { "Feb 23, 2014" },
new object[] { "<=0 growth" },
new object[] { "abcd" },
new object[] { "bye" },
new object[] { "Oct 04 2014" }
};

this.Store1.DataBind();
}
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET Sample</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server"/>

<ext:GridPanel runat="server" Title="Sample">
<Store>
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="max_date" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server" >
<Columns>
<ext:Column
runat="server"
Text="Max Date"
DataIndex="max_date"
Width="200"
/>
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>

Sowjanya
Apr 24, 2014, 7:49 PM
Hi, this is a working code where I tested in my local machine and confirmed it works, atleast for the the last post code.
and fyi, it did not require additional objects like scripts etc etc...
I just pasted the whole aspx working code, along with server code.
Still wondering why it is cauisng issues...

Sowjanya
Apr 24, 2014, 8:30 PM
yes. so how could the custom sorting be implemented on this column now?

Vladimir
Apr 25, 2014, 5:02 AM
You can use CustomSortType property of ModelField


<ext:ModelField ....>
<CustomSortType Fn="mySortFn" />
</ext:ModelField>


It sould be a function which converts a Field's value to a comparable value in order to ensure correct sort ordering.
Example of sort function


// current sort after sort we want
// +-+------+ +-+------+
// |1|First | |1|First |
// |2|Last | |3|Second|
// |3|Second| |2|Last |
// +-+------+ +-+------+

sortType: function(value) {
switch (value.toLowerCase()) // native toLowerCase():
{
case 'first': return 1;
case 'second': return 2;
default: return 3;
}
}

Sowjanya
Apr 25, 2014, 8:32 PM
how is "mySortFn" related to "sortType: function(value)" ?how should I plug in this code in my aspx page ?

geoffrey.mcgill
Apr 25, 2014, 9:15 PM
how is "mySortFn" related to "sortType: function(value)" ?how should I plug in this code in my aspx page ?

It's an example. You will have to implement your own custom sort function and logic.

The following sample demonstrates how all the pieces are wired together, but you will have to implement the logic of the sort based on your requirements.

Example


<%@ Page Language="C#" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.Store1.DataSource = new object []
{
new object[] { "Jan 23, 2014" },
new object[] { "Feb 23, 2014" },
new object[] { "<=0 growth" },
new object[] { "abcd" },
new object[] { "bye" },
new object[] { "Oct 04 2014" }
};

this.Store1.DataBind();
}
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET Sample</title>

<script type="text/javascript">
var mySortFn = function (value) {
// implement your custom sort logic here

// return the value as another type, for example
// convert the values to a Date.

// You will have to implement custom Date parsing, as the
// following will fail on random string values
// return Ext.Date.parse(value);

return value;
};
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server"/>

<ext:GridPanel runat="server" Title="Sample">
<Store>
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="max_date">
<CustomSortType Fn="mySortFn" />
</ext:ModelField>
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server" >
<Columns>
<ext:Column
runat="server"
Text="Max Date"
DataIndex="max_date"
Width="200"
/>
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>

Hope this helps.

Sowjanya
Apr 25, 2014, 9:32 PM
but, in order to sort, i need to have access to all other records in this store, where only then i will be able to find out which is the highest value of this field, , 2nd highest value of this field etc..etc and then return them...but this function has got only the current record's value.
How will I be able to achieve this ?

Daniil
Apr 28, 2014, 8:18 AM
Hi @Sowjanya,

Another option...

If you need such kind of sorting by click on a column header, we can suggest to use a Store's RemoteSort="true" and sort on server side as needed.
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.Store-cfg-remoteSort

Please see this example:
http://examples2.ext.net/#/GridPanel/Plugins/GridFilters_Remote/

geoffrey.mcgill
Apr 28, 2014, 3:37 PM
but, in order to sort, i need to have access to all other records in this store, where only then i will be able to find out which is the highest value of this field, , 2nd highest value of this field etc..etc and then return them...but this function has got only the current record's value.

You need to return a string, int, boolean or Date object from your custom sort logic. Once one of those data types is returned, then the Store will be able to sort the records. It is up to your own logic to decide which value to return.

Sowjanya
Apr 28, 2014, 6:11 PM
Okay, thanks..let me try and update if it works !

Sowjanya
Apr 30, 2014, 7:58 PM
Okay, thanks..let me try and update if it works !

Hi Geoff,

Thanks a lot, It worked..Pls close this ticket. !