PDA

View Full Version : [OPEN] [#1366] ListFilter sorting for GridFilters plugin



kwcitadmin
Aug 03, 2016, 10:21 AM
Is there any config to sort options for ListFilter?

Here is an example that the Company options, which orders same as data.


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

<%@ Import Namespace="System.Collections.Generic" %>
<script runat="server">

protected void Page_Load(object sender, EventArgs e)
{

StoreData.DataSource = new List<object>
{
new
{
Id = 1,
Company = "ZZZ Co",
},
new
{
Id = 2,
Company = "Aloca Inc",
},
new
{
Id = 3,
Company = "Altria Group Inc",
},
new
{
Id = 4,
Company = "American Express Company",
},
new
{
Id = 5,
Company = "American International Group Inc.",
}
};

StoreData.DataBind();
}

</script>



<!DOCTYPE html>

<html>
<head runat="server">


</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:Window
runat="server"
Width="700"
Height="400"
Title="Example"
Layout="Fit">
<Items>
<ext:GridPanel ID="GridPanel1" runat="server" Border="false">
<Store>
<ext:Store
ID="StoreData"
runat="server"
PageSize="10">
<Model>
<ext:Model runat="server" IDProperty="Id">
<Fields>
<ext:ModelField Name="Id" Type="Int" />
<ext:ModelField Name="Company" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="ID" DataIndex="Id">
<Filter>
<ext:NumberFilter />
</Filter>
</ext:Column>
<ext:Column ID="CompanyColumn" runat="server" Text="Company" DataIndex="Company">
<Filter>
<ext:ListFilter />
</Filter>
</ext:Column>
</Columns>
</ColumnModel>
<Plugins>
<ext:GridFilters runat="server" />
</Plugins>
<BottomBar>
<ext:PagingToolbar runat="server" />
</BottomBar>
</ext:GridPanel>
</Items>
</ext:Window>
</form>
</body>
</html>

fabricio.murta
Aug 05, 2016, 3:50 AM
Hello @kwcitadmin!

Sorry for the delay, for some reason I didn't see your post, so it took some time until my mistake was found!

Well, bad news is that sorting the list in the list filter is not supported without some change.

Good news is that it is not really difficult to implement support on your page:



<script type="text/javascript">
Ext.define('Ext.grid.filters.filter.List', {
override: 'Ext.grid.filters.filter.List',
createListStore: function (options) {
var me = this;

me.callParent(arguments);

if (me.store) {
me.store.sort('text');
}
}
})
</script>


I hope this helps!

kwcitadmin
Aug 05, 2016, 4:11 AM
My premium support was just resumed and the post was moved by Geoffrey.

Thx for your prompt reply. Really impressed!

kwcitadmin
Aug 05, 2016, 4:24 AM
Sorting is nice for some cases while custom order is useful for other cases, e.g. size in following sample http://examples.ext.net/#/GridPanel/Plugins/GridFilters_Local/ .

It would be nice if a config could be added to ListFilter in later version :)

fabricio.murta
Aug 05, 2016, 4:37 AM
Hello again, @kwcitadmin!

Alright, you got it. We've logged a feature issue to implement this on Ext.NET under ID #1366 (https://github.com/extnet/Ext.NET/issues/1366).

This is not so simple and straightforward to just implement it because, as a full-fledged ExtJS component, making changes our side may mean conflicts in the future, may Sencha implement this feature on their side, so careful logging and tracking is needed once anything fully implemented in ExtJS is changed.

If that was an exclusive Ext.NET feature, that would be easier to just go ahead and implement.

With the feature logged now we can also track whether other users are demanding such a feature and prioritize what's most missed in the framework! We hope you understand.

kwcitadmin
Aug 05, 2016, 4:44 AM
thx.
Look forward to the good news!