PDA

View Full Version : [CLOSED] How to set gridfilter from code



CarWise
Nov 26, 2012, 11:21 AM
Hi,

can't figure out how to set initial gridfilter value (stringfilter) from code (server)..

Could you give a small example ?

Martin

Daniil
Nov 26, 2012, 11:26 AM
Hi Martin,

Please use StringFilter's Value property.

StringFilter f = new StringFilter();
f.Value = "initial value";

CarWise
Nov 26, 2012, 11:35 AM
Hi Martin,

Please use StringFilter's Value property.

StringFilter f = new StringFilter();
f.Value = "initial value";

I'm not creating the filters in code but I can do that offcourse. But just wondering how to set the initial value when having this:



<ext:GridFilters runat="server" ID="gfIssues" Local="true">
<Filters>
<ext:NumericFilter DataIndex="ID" />
<ext:StringFilter DataIndex="cIssueSoort" />
<ext:StringFilter DataIndex="cGroep" />
<ext:StringFilter DataIndex="cTitel" />
<ext:NumericFilter DataIndex="nKlantID" />
<ext:StringFilter DataIndex="clNaamContact" />
<ext:StringFilter DataIndex="cPakket" />
<ext:StringFilter DataIndex="cTags" />
<ext:StringFilter DataIndex="cBuildNummer" />
<ext:DateFilter DataIndex="nDatumAanmaak" AutoDataBind="true">
<DatePickerOptions runat="server" Format="dd-MM-yyyy" TodayText="Now" />
</ext:DateFilter>
<ext:StringFilter DataIndex="nTijd" />
<ext:StringFilter DataIndex="cClusterNaam" />
</Filters>
</ext:GridFilters>


I can't set an ID for the filters, so how can I get the right filter. Only by index ?

And also..how to set the numericfilter value (as this property is non existing) ?

Martin

Daniil
Nov 26, 2012, 3:16 PM
I can't set an ID for the filters, so how can I get the right filter. Only by index ?


Or search for DataIndex. Maybe, it would be better to just add a StringFilter instance with all required setting to the Filters collection.



And also..how to set the numericfilter value (as this property is non existing) ?


There are the EqualValue, GreaterThanValue and LessThanValue properties at your service.

CarWise
Nov 26, 2012, 4:13 PM
Or search for DataIndex. Maybe, it would be better to just add a StringFilter instance with all required setting to the Filters collection.



There are the EqualValue, GreaterThanValue and LessThanValue properties at your service.

duh.. sorry .. was really looking for a value property that doesn't exist ofcourse.. :[ (wake up Martin)

What is the reason btw that there is no possibility to add an ID to a gridfilter (just curious)

Martin

Daniil
Nov 26, 2012, 4:52 PM
What is the reason btw that there is no possibility to add an ID to a gridfilter (just curious)

Well, it is not a real control. Just a class to get some JavaScript in the output.

CarWise
Nov 26, 2012, 5:52 PM
Well, it is not a real control. Just a class to get some JavaScript in the output.

Thanx for the info Daniil. Next time I will drink some coffee before asking you for a property that doesn't exist :)

martin