This is a migrated thread and some comments may be shown as answers.
Load on Demand for Filtering
3 Answers 31 Views
This is a migrated thread and some comments may be shown as answers.
John John
Top achievements
Rank 1
John John asked on 13 Apr 2010, 11:04 AM

Dear Telerik,

            Kindly directme to solve the scenario of loading the combo box based on the value of the recentcombo selection. After initially loading the values to all combo’s, if I choosethe value of the first combo and do filtering the second combo should need tofill with the available values instead of binding the whole items from the DB.

I could see that the scenario is elaborated with the Telerikfiltering demo, but used the Sqldatasource and calls the Refresh method in orderto achieve the scenario.

 protected void RefreshCombos() 
        { 
            SqlDataSource2SqlDataSource2.SelectCommand = SqlDataSource2.SelectCommand + " WHERE " + RadGrid1.MasterTableView.FilterExpression.ToString(); 
            SqlDataSource3SqlDataSource3.SelectCommand = SqlDataSource3.SelectCommand + " WHERE " + RadGrid1.MasterTableView.FilterExpression.ToString(); 
            SqlDataSource4SqlDataSource4.SelectCommand = SqlDataSource4.SelectCommand + " WHERE " + RadGrid1.MasterTableView.FilterExpression.ToString(); 
 
            RadGrid1.MasterTableView.Rebind(); 
        } 
 

 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        // Filter controls value binding 
        if (e.Item.ItemType == GridItemType.FilteringItem) 
        { 
            DataSet dsStates = null
 
            RadTextBox txtName; 
            txtName = (RadTextBox)e.Item.FindControl("txtName"); 
            if (ViewState["txtName"] != null) 
            { 
                txtName.Text = ViewState["txtName"].ToString(); 
            } 
                         
             RadComboBox StateComboBox; 
            StateComboBox = (RadComboBox)e.Item.FindControl("StateComboBox"); 
            sql = "sp_GetNames "
            StateComboBox.ClearSelection(); 
            StateComboBox.DataSource = dsStates.Tables[0]; 
            StateComboBox.DataTextField = "State"
            StateComboBox.DataValueField = "State"
            StateComboBox.DataBind(); 
            StateComboBox.Items.Insert(0, new RadComboBoxItem("   All ", " All ")); 
            StateComboBox.SelectedIndex = 0
             
            if (ViewState["txtState"] != null) 
            { 
                StateComboBox.FindItemByText(ViewState["txtState"].ToString()).Selected = true;                
            } 

protected void StateComboBox_IndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) 
    { 
        //Code for customized server side filtering           
        string filterState = ""
        if (e.Text.Trim() != "All") 
        { 
            filterState = "([State] = '" + e.Text + "')"; 
        } 
        else 
        { 
            filterState = "([State] <> '')"
        } 
 
        ViewState["txtState"] = e.Text.ToString(); 
        vwState = filterState
 
        if (vwGroupID != null) 
        { 
            filterState += " And " + vwGroupID; 
        } 
 
        //Calling FilterExpression finally 
        RadGrid1.MasterTableView.FilterExpression = filterState
        RadGrid1.MasterTableView.Rebind(); 
    } 

I could not find the best way to do the scenario with dynamicallycreated combo as it is achieved in Telerik demo for filtering

Thanks and looking forward for yours ideas

3 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 16 Apr 2010, 07:17 AM
Hi John,

The following code library entry contains additional information on a possible approach:

http://www.telerik.com/community/code-library/aspnet-ajax/general/using-related-radcomboboxes-in-radgrid.aspx

I hope it gets you started properly.

All the best,
Yavor
the Telerik team


Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
John John
Top achievements
Rank 1
answered on 16 Apr 2010, 08:00 AM
Hi Yavor,
                    The above mentioned link did help me to know how to bind the drop down in demand. But i would like to know whether it is applicable with Filter Template combo's. As i mentioned above i would like to load the combo on demand dynamically by coding without using SqlDatasource.

Hope  now you could point my scenario.

-Thanks
0
Yavor
Telerik team
answered on 19 Apr 2010, 11:56 AM
Hi John,

The same approach is applicable in a filter template as well. Essentially, in the SelectedIndexChanged handler, you can alter the datasource of the related control.

Sincerely yours,
Yavor
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
John John
Top achievements
Rank 1
Answers by
Yavor
Telerik team
John John
Top achievements
Rank 1
Share this question
or