PDA

View Full Version : [CLOSED] Add Dynamic Filters to Dynamic Gridpanel



CarWise
Aug 21, 2014, 2:27 PM
Hi guys,

Fresh back from almost 2 months traveling in Australia, but have to work again :(

Trying to add gridfilters to a dynamic filter. Created a small example.
Filters are not appearing....any help appreciated :)

aspx


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="FleetWise.Test.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Dynamic test</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager ID="rmOverzichten" runat="server" CleanResourceUrl="false" />
<ext:GridPanel runat="server" ID="dgvGrid">
<Store>
<ext:Store runat="server" ID="dgvStore">
<Model>
<ext:Model runat="server"/>
</Model>
</ext:Store>
</Store>
</ext:GridPanel>

<ext:Button runat="server" Text="Fill grid" OnDirectClick="btn_click"></ext:Button>


</div>
</form>
</body>
</html>


c#


using System;
using Ext.Net;


namespace FleetWise.Test
{
public partial class Default : System.Web.UI.Page
{
protected void btn_click(object sender, DirectEventArgs e)
{
dgvStore.AddField(new ModelField("Text", ModelFieldType.String));
dgvStore.AddField(new ModelField("DateTime", ModelFieldType.Date));
dgvGrid.ColumnModel.Columns.Add(new Column()
{
DataIndex = "Text",
Text = "Text Column"
});


dgvGrid.ColumnModel.Columns.Add(new Column()
{
DataIndex = "DateTime",
Text = "Date Column"
});



// Trying to add filters to grid
GridFilters gf = new GridFilters();

StringFilter sf = new StringFilter();
sf.DataIndex = "Text";
gf.Filters.Add(sf);


DateFilter df = new DateFilter();
df.DataIndex = "DateTime";
gf.Filters.Add(df);


dgvGrid.Features.Add(gf);
// END


dgvGrid.Reconfigure();
dgvStore.RebuildMeta();
dgvStore.DataSource = new[]
{
new
{
Text = "Text1",
DateTime = DateTime.Now
},
new
{
Text = "Text2",
DateTime = DateTime.Now
}
};
dgvStore.DataBind();




}
}
}



Martin

Daniil
Aug 21, 2014, 2:31 PM
Hi Martin,

I would like to visit Australia ever as well:)

A GridPanel's .Reconfigure() can reconfigure columns and store, that is it.

To add filters to a GridFilters plugin on the fly, you are going to rerender a GridPanel at all.

CarWise
Aug 21, 2014, 2:45 PM
Great country...friendly people..beautiful nature. Little bit expensive though, but it was worth it.

Rerender ? Can you eidt this small example to get it working ? :)

I've tried gridpanel.ReRender() instead of reconfigure, but still no filters..

Martin

Daniil
Aug 21, 2014, 3:00 PM
Nice. I am packing:)

I've just replaced

dgvGrid.Reconfigure();
with

dgvGrid.ReRender();
and that is the only thing I've done. The filters appear for me.

Could you, please, provide a test case to reproduce?

CarWise
Aug 21, 2014, 3:24 PM
mmmm... sorry.. my bad..

You're right. Works like a charm.

Thanks !

Martin