Hey Folks,
After checking out the "Google Filtering" demo, and the accompanying article here http://www.telerik.com/support/kb/aspnet-ajax/grid/google-suggest-style-filtering-in-radgrid.aspx I set out to accomplish something similar. Everything worked well but I felt that there must be a better way than programatically swapping out the columns.
In my <Columns> Collection for the RadGrid I put the following:
<Columns>
<rg:TelerikGoogleFilterColumnNomenclature CurrentFilterFunction="Contains"
DataField="Nomenclature" FilterListOptions="VaryByDataType"
ForceExtractValue="None" HeaderText="Nomenclature" UniqueName="Nomenclature" >
</rg:TelerikGoogleFilterColumnNomenclature>
<rg:TelerikGoogleFilterColumnPartNumbers CurrentFilterFunction="Contains"
DataField="PartNumber" FilterListOptions="VaryByDataType"
ForceExtractValue="None" Groupable="False" HeaderText="PartNumber"
ReadOnly="True" UniqueName="PartNumber">
</rg:TelerikGoogleFilterColumnPartNumbers>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Cost"
DataType="System.Int32" FilterListOptions="VaryByDataType"
ForceExtractValue="None" HeaderText="Cost" UniqueName="Cost" DataFormatString="{0:c}" >
</telerik:GridBoundColumn>
...
...
...
</Columns>
And added an entry into web.config for the "rg" prefix like so:
<add tagPrefix="rg" namespace="RadGrid" />
My Class file containing (straight from the article) the Filter Column Contained the following:
public class TelerikGoogleFilterColumn : GridBoundColumn
{
//override the following to change path/method in a child
public virtual string GetWebServicePath()
{
return "./MyService.asmx";
}
public virtual string GetWebServiceMethod()
{
return "SomeMethod";
}
protected override void SetupFilterControls(TableCell cell)
{
base.SetupFilterControls(cell);
cell.Controls.RemoveAt(0);
RadComboBox combo = new RadComboBox();
combo.ID = ("RadComboBox1" + this.DataField);
combo.ShowToggleImage = false;
combo.Skin = "WebBlue";
combo.EnableLoadOnDemand = true;
combo.AutoPostBack = true;
combo.MarkFirstMatch = false;
combo.Height = Unit.Pixel(280);
combo.Width = Unit.Pixel(300);
//combo.ItemsRequested += new RadComboBoxItemsRequestedEventHandler(this.list_ItemsRequested);
combo.SelectedIndexChanged += new Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventHandler(this.list_SelectedIndexChanged);
//setup web service info here
combo.WebServiceSettings.Path = GetWebServicePath();
combo.WebServiceSettings.Method = GetWebServiceMethod();
combo.ShowToggleImage = false;
combo.NoWrap = true;
cell.Controls.AddAt(0, combo);
cell.Controls.RemoveAt(1);
}
... etc
This works out as I simply override the method/path values for different columns and dont have to manipulate the grid at runtime.
Just thought it would be useful for others. Works ALOT simpler for me anyways :)
After checking out the "Google Filtering" demo, and the accompanying article here http://www.telerik.com/support/kb/aspnet-ajax/grid/google-suggest-style-filtering-in-radgrid.aspx I set out to accomplish something similar. Everything worked well but I felt that there must be a better way than programatically swapping out the columns.
In my <Columns> Collection for the RadGrid I put the following:
<Columns>
<rg:TelerikGoogleFilterColumnNomenclature CurrentFilterFunction="Contains"
DataField="Nomenclature" FilterListOptions="VaryByDataType"
ForceExtractValue="None" HeaderText="Nomenclature" UniqueName="Nomenclature" >
</rg:TelerikGoogleFilterColumnNomenclature>
<rg:TelerikGoogleFilterColumnPartNumbers CurrentFilterFunction="Contains"
DataField="PartNumber" FilterListOptions="VaryByDataType"
ForceExtractValue="None" Groupable="False" HeaderText="PartNumber"
ReadOnly="True" UniqueName="PartNumber">
</rg:TelerikGoogleFilterColumnPartNumbers>
<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Cost"
DataType="System.Int32" FilterListOptions="VaryByDataType"
ForceExtractValue="None" HeaderText="Cost" UniqueName="Cost" DataFormatString="{0:c}" >
</telerik:GridBoundColumn>
...
...
...
</Columns>
And added an entry into web.config for the "rg" prefix like so:
<add tagPrefix="rg" namespace="RadGrid" />
My Class file containing (straight from the article) the Filter Column Contained the following:
public class TelerikGoogleFilterColumn : GridBoundColumn
{
//override the following to change path/method in a child
public virtual string GetWebServicePath()
{
return "./MyService.asmx";
}
public virtual string GetWebServiceMethod()
{
return "SomeMethod";
}
protected override void SetupFilterControls(TableCell cell)
{
base.SetupFilterControls(cell);
cell.Controls.RemoveAt(0);
RadComboBox combo = new RadComboBox();
combo.ID = ("RadComboBox1" + this.DataField);
combo.ShowToggleImage = false;
combo.Skin = "WebBlue";
combo.EnableLoadOnDemand = true;
combo.AutoPostBack = true;
combo.MarkFirstMatch = false;
combo.Height = Unit.Pixel(280);
combo.Width = Unit.Pixel(300);
//combo.ItemsRequested += new RadComboBoxItemsRequestedEventHandler(this.list_ItemsRequested);
combo.SelectedIndexChanged += new Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventHandler(this.list_SelectedIndexChanged);
//setup web service info here
combo.WebServiceSettings.Path = GetWebServicePath();
combo.WebServiceSettings.Method = GetWebServiceMethod();
combo.ShowToggleImage = false;
combo.NoWrap = true;
cell.Controls.AddAt(0, combo);
cell.Controls.RemoveAt(1);
}
... etc
This works out as I simply override the method/path values for different columns and dont have to manipulate the grid at runtime.
Just thought it would be useful for others. Works ALOT simpler for me anyways :)