This is a migrated thread and some comments may be shown as answers.

RadGrid filtering using a RadComboBox of checkboxes?

1 Answer 163 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 09 Apr 2012, 02:30 PM
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:
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?

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 13 Apr 2012, 07:41 AM
Hi Chris,

Can you please try to enable the checkboxes mode of RadComboBox by setting the combobox's CheckBoxes property to "True" and see if it works properly.
http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/checkboxes/defaultcs.aspx

Additionally, to enable Check All functionality you should set EnableCheckAllItemsCheckBox property to true.

Please give this suggestion a try and let me know how it goes.

Regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or