PDA

View Full Version : [CLOSED] Grid Filter Default Value



canusr1
Sep 04, 2013, 9:30 AM
Hello,

I have a boolean grid filter and want to set that filter's default value as 'False' when grid is loaded.

It supposed to be set 'True' if I set 'True' in grid's filter.

Now, grid loading is 'False' on grid loading but however I set filter to 'True', the grid filter remains the same as 'False'.

Please check the following code. Thanks.



<ext:GridFilters Local="true">
<Filters>
<ext:BooleanFilter DataIndex="IGNORE_FLAG" />
</Filters>
</ext:GridFilters>




<View>
<ext:GridView ID="GridView1" runat="server" StripeRows="true" TrackOver="true">
<Listeners>
<Refresh Handler="#{gvInvoiceList}.body.unmask();#{gvInvoiceList}.ge tFilterPlugin().getFilter('IGNORE_FLAG').setValue( true);" Delay="1" />
</Listeners>
</ext:GridView>
</View>

Daniil
Sep 04, 2013, 1:40 PM
Hi @canusr1,

Please update from SVN and use:

<ext:BooleanFilter DataIndex="test" Value="false" />

Example

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

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
Store store = this.GridPanel1.GetStore();
store.DataSource = new object[]
{
new object[] { true },
new object[] { false },
new object[] { true }
};
}
}
</script>

<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:GridPanel ID="GridPanel1" runat="server">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="test" Type="Boolean" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Test" DataIndex="test" />
</Columns>
</ColumnModel>
<Features>
<ext:GridFilters runat="server" Local="true">
<Filters>
<ext:BooleanFilter DataIndex="test" Value="false" />
</Filters>
</ext:GridFilters>
</Features>
</ext:GridPanel>
</form>
</body>
</html>

If you cannot or do not want to update, please use this fix:

<script>
Ext.ux.grid.filter.Filter.override({
constructor : function (config) {
Ext.apply(this, config);

this.addEvents(
/**
* @event activate
* Fires when an inactive filter becomes active
* @param {Ext.ux.grid.filter.Filter} this
*/
'activate',
/**
* @event deactivate
* Fires when an active filter becomes inactive
* @param {Ext.ux.grid.filter.Filter} this
*/
'deactivate',
/**
* @event serialize
* Fires after the serialization process. Use this to attach additional parameters to serialization
* data before it is encoded and sent to the server.
* @param {Array/Object} data A map or collection of maps representing the current filter configuration.
* @param {Ext.ux.grid.filter.Filter} filter The filter being serialized.
*/
'serialize',
/**
* @event update
* Fires when a filter configuration has changed
* @param {Ext.ux.grid.filter.Filter} this The filter object.
*/
'update'
);
Ext.ux.grid.filter.Filter.superclass.constructor.c all(this);

this.menu = this.createMenu(config);
this.init(config);

if (config && Ext.isDefined(config.value)) {
this.setValue(config.value);
this.setActive(config.active !== false, true);
delete config.value;
}
}
});
</script>

canusr1
Sep 05, 2013, 3:07 AM
It's working fine now. Thanks for the help. :D