Originally Posted by
Daniil
Regarding the markup (code behind).
The third way looks just:
<ext:ListFilter DataIndex="test1" Options="test11, test12, test13" />
Yes I understand that, but that doesn't work in my case, because the column values in the store are different from the displayed column values. I need the first or second way from the documentation I posted, because the store content doesn't match what is displayed.
Originally Posted by
Daniil
The second way can look like this:
<ext:ListFilter DataIndex="test" StoreID="Store1" LabelField="test" />
http://forums.ext.net/showthread.php...ll=1#post38965
But I have discovered a problem with the example from this thread. It doesn't work with the latest code. We are working on the fix.
Could you test this example using Ext.Net RC1?
I've tested the linked example. It seems to work in RC1 except that filter items get removed after checking them. In any way it is not what I need. It builds the list of filters from the store, but that means in my case I end up with a list of numbers.
Here's an example of what I want to do (code-behind is empty):
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="GridTest._Default" %>
<%@ Register TagPrefix="ext" Namespace="Ext.Net" Assembly="Ext.Net" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="Ext.Net" %>
<!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></title>
</head>
<body>
<form runat="server" id="wForm">
<div>
<ext:ResourceManager runat="server" ID="wResMgr" />
<ext:GridPanel runat="server" ID="wGrid" Width="600" Height="400">
<Store>
<ext:Store runat="server" ID="wStore" OnRefreshData="wStore_Refresh">
<Reader>
<ext:ArrayReader>
<Fields>
<ext:RecordField Name="key" Type="String" />
<ext:RecordField Name="value" Type="Int" />
</Fields>
</ext:ArrayReader>
</Reader>
</ext:Store>
</Store>
<ColumnModel runat="server" ID="wColumns">
<Columns>
<ext:Column Header="Line" DataIndex="key" />
<ext:Column Header="Value" DataIndex="value">
<Renderer Handler="function(v){return {0:'empty',1:'value 1',2:'value 2'}[v];}" />
</ext:Column>
</Columns>
</ColumnModel>
<Plugins>
<ext:GridFilters runat="server" ID="wFilter" />
</Plugins>
</ext:GridPanel>
</div>
</form>
</body>
</html>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
ListFilter filter = new ListFilter();
filter.DataIndex = "value";
filter.Options = new string[] { "empty", "value 1", "value 2" }; // this does not work
wFilter.Filters.Add(filter);
if (!X.IsAjaxRequest)
{
wStore.DataSource = this.Data.ToArray();
wStore.DataBind();
}
}
protected void wStore_Refresh(object sender, StoreRefreshDataEventArgs e)
{
IEnumerable<object[]> data = this.Data;
string rawFilter = e.Parameters["filter"];
if(!string.IsNullOrEmpty(rawFilter))
{
var filter = new FilterConditions(rawFilter);
foreach (var cond in filter.Conditions)
{
if (cond.FilterType != FilterType.List || cond.Comparison != Comparison.Eq || cond.Name != "value")
throw new NotImplementedException();
// doesn't work because we get passed the text values and not the column values we wanted to filter
var filterValues = cond.ValuesList;
data = data.Where(obj => filterValues.Contains(obj[1].ToString()));
}
}
wStore.DataSource = data.ToArray();
}
private IEnumerable<object[]> Data
{
get
{
for (int i = 0; i < 100; i++)
yield return new object[] { "line" + i, i % 3 };
}
}
</script>
When I examine the generated javascript from the browser I find following snippet:
new Ext.ux.grid.GridFilters({
filters: [{
dataIndex: "value",
type: "list",
options: ["empty","value 1","value 2"]
}]
})
What I need is to specify a mapping, if you look at the documentation of ListFilter.js I posted above you are supposed to do a mapping this way:
new Ext.ux.grid.GridFilters({
filters: [{
dataIndex: "value",
type: "list",
options: [[0,"empty"],[1,"value 1"],[2,"value 2"]]
}]
})
How do I get Ext.Net do generate such a mapping?