PDA

View Full Version : [CLOSED] Add GridFilters after Gridpanel reconfigure MVC



RCM
Aug 24, 2012, 3:27 AM
Hi,

I am trying to add gridfilters to my Gridpanel after it is reconfigured, but the filters are not being added. See sample below, I think i may not be adding filters in correct order. please advise.



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

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
<script type="text/javascript" src="scripts/MyProxy.js"></script>
<script type="text/javascript">
var getData = function (operation) {
var start = operation.start,
limit = operation.limit,
date = new Date(),
i,
data = [];

for (i = start + 1; i <= start + limit; i++) {
data.push({
test1: "Company " + i,
test2: parseInt(Math.random() * 200),
LastUpdate: date
});
}

return {
data: data,
total: 200
};
};

var myProxyConfig = {
type: 'myproxy',
onReadData: getData,
reader: {
type: 'json',
root: 'data',
totalProperty: 'total'
}
};

var reconfigureGrid = function () {
var grid = Ext.getCmp("GridPanel1"),
store,
columns;

store = new Ext.data.JsonStore({
remoteSort: true,
buffered: true,
pageSize: "100",
fields: [{ name: "test1" }, { name: "test2"}],
showWarningOnFailure: false,
proxy: myProxyConfig
});

columns = [{
dataIndex: "test1",
text: "Test1"
}, {
dataIndex: "test2",
text: "Test2"
}];

store.trailingBufferZone = 25;
store.leadingBufferZone = 0;

grid.reconfigure(store, columns);

App.gridFiltersGridView.filters.clear();
App.gridFiltersGridView.filters.add({ type: 'string', dataIndex: 'test1' });
App.gridFiltersGridView.filters.add({ type: 'string', dataIndex: 'test2' });

store.loadPage(1);
};

</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:GridPanel ID="GridPanel1" runat="server" Width="500" Height="500" DisableSelection="true"
Title="Stock Price">
<TopBar>
<ext:Toolbar runat ="server">
<Items>
<ext:Button runat ="server" Text = "reconfgure">
<Listeners>
<Click Handler="reconfigureGrid();" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<Store>
<ext:Store runat="server" Buffered="true" PageSize="100">
<CustomConfig>
<ext:ConfigItem Name="proxy" Value="myProxyConfig" Mode="Raw" />
</CustomConfig>
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="Company" />
<ext:ModelField Name="Price" />
<ext:ModelField Name="LastUpdate" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:RowNumbererColumn runat="server" Width="50" Sortable="false" />
<ext:Column runat="server" Text="Company" DataIndex="Company" Flex="1" />
<ext:Column runat="server" Text="Price, $" DataIndex="Price" Width="70" Align="Center" />
<ext:Column runat="server" Text="Last Update" DataIndex="LastUpdate" Width="140">
<Renderer Format="Date" FormatArgs="'n/j/Y g:i:s A'" />
</ext:Column>
</Columns>
</ColumnModel>
<Features>
<ext:GridFilters runat="server" ID="gridFiltersGridView"
AutoDataBind="true">
<Filters>
</Filters>
</ext:GridFilters>
</Features>
<View>
<ext:GridView runat="server" TrackOver="false" />
</View>
<Listeners>

</Listeners>
</ext:GridPanel>
</form>
</body>
</html>

Daniil
Aug 24, 2012, 5:04 AM
Hi,

Please use the addFilter method.
http://docs.sencha.com/ext-js/4-1/source/FiltersFeature.html#Ext-ux-grid-FiltersFeature

Example

App.GridPanel1.filters.addFilter({
type : 'string',
dataIndex : 'test1'
});

Also I think that you should set up

Local="true"
for the GridFilters.

RCM
Aug 24, 2012, 4:12 PM
hi
Thanks, please mark as closed.