I have a radgrid bound to a sqldatasource, I have the columns using a radcombobox. What I want to do is switch some of the columns to use checkboxes like on this example:
http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/templates/defaultcs.aspx
The only other thing I've been able to find on this is from this forum from 2009:
http://www.telerik.com/community/forums/aspnet-ajax/grid/radgrid-filtering-using-a-radcombobox-of-checkboxes.aspx
But first mine is all declared in the aspx file, and second everything else is changing the filter using a js call like:
While that forum post ends with a:
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("ContactTitle," + text );
That calls a function on the code behind:
What is the best way to do what I'm trying to do, and if that's the only way to do the checkboxes (using the ajax call) how do I modify the sqldatasource from the ajax call so that it doesn't mess up the rest of the filtering?
Update:
I created a control that inherits from GridTemplateColumn,
In there I do:
my rcBox_ItemChecked looks like this:
in the:
http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/templates/defaultcs.aspx
The only other thing I've been able to find on this is from this forum from 2009:
http://www.telerik.com/community/forums/aspnet-ajax/grid/radgrid-filtering-using-a-radcombobox-of-checkboxes.aspx
But first mine is all declared in the aspx file, and second everything else is changing the filter using a js call like:
var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>"); tableView.filter("CustomerName", args.get_item().get_value(), "EqualTo");
While that forum post ends with a:
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("ContactTitle," + text );
That calls a function on the code behind:
private void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) |
{ |
if(e.Argumnet.ToString().Split[','][0]=="ContactTitle") |
{ |
//Access the rest of the string and set the filter Expression |
} |
} |
What is the best way to do what I'm trying to do, and if that's the only way to do the checkboxes (using the ajax call) how do I modify the sqldatasource from the ajax call so that it doesn't mess up the rest of the filtering?
Update:
I created a control that inherits from GridTemplateColumn,
In there I do:
RadComboBox rcBox = new RadComboBox(); rcBox.ID = "DropDownList_" + DataField; rcBox.AutoPostBack = true; rcBox.DropDownWidth = DropDownWidth; rcBox.Width = FilterControlWidth; rcBox.CheckBoxes = true; rcBox.ItemChecked += rcBox_ItemChecked; rcBox.Height = Unit.Pixel(200);
DataTable table = GetDataTable(string.Format("SELECT DISTINCT cast({0} as varchar) as {0} FROM {1} Where 1=1 {2} order by {0} asc", this.DataField, TableName, where)); rcBox.DataTextField = this.DataField; rcBox.DataValueField = this.DataField; rcBox.DataSource = table; cell.Controls.Add(rcBox);
my rcBox_ItemChecked looks like this:
private void rcBox_ItemChecked(object sender, Telerik.Web.UI.RadComboBoxItemEventArgs e) { ((GridFilteringItem)(((RadComboBox)sender).Parent.Parent)).FireCommandEvent("Filter", new Pair()); }
in the:
protected override void SetCurrentFilterValueToControl(TableCell cell)and:
protected override string GetCurrentFilterValueFromControl(TableCell cell) How can I access the checkboxs? And how do I add or filtering best?