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

Google like filtering, loading statement with no results

1 Answer 48 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Giovanni
Top achievements
Rank 1
Giovanni asked on 22 Oct 2010, 02:35 PM

Hello,

I'm experiencing some trouble in the google-like filtering demo ( http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandcombo/defaultcs.aspx?product=grid ).

The ItemRequested event is never fired, Loading statement stands forever without displaying any results.

This is my implementation of the gridboundcolumn :

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 = false;

    combo.MarkFirstMatch = true;

    combo.Height = Unit.Pixel(100);

    combo.ItemsRequested += new RadComboBoxItemsRequestedEventHandler(this.combo_ItemsRequested);           

    combo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(this.list_SelectedIndexChanged);

    //cell.Controls.Clear();

    cell.Controls.AddAt(0, combo);

    cell.Controls.RemoveAt(1);

}

 

//RadGrid will call this method when the value should be set to the filtering input control(s)

protected override void SetCurrentFilterValueToControl(TableCell cell)

{

    base.SetCurrentFilterValueToControl(cell);

    RadComboBox combo = (RadComboBox)cell.Controls[0];

    if ((this.CurrentFilterValue != string.Empty))

    {

        combo.Text = this.CurrentFilterValue;

    }

}

 

//RadGrid will cal this method when the filtering value should be extracted from the filtering input control(s)

protected override string GetCurrentFilterValueFromControl(TableCell cell)

{

    RadComboBox combo = (RadComboBox)cell.Controls[0];

    return combo.Text;

}

 

private void combo_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)

{           

    ((RadComboBox)o).DataTextField = this.DataField;

    ((RadComboBox)o).DataValueField = this.DataField;

 

    if (this.UniqueName == "Autore")

    {

        try

        {

            ((RadComboBox)o).DataSource = MYSOLUTION.DataLayer.GestioneAnomalie.GestioneAnomalieDataProvider.GetAutori(e.Text);

        }

        catch (Exception ex)

        {

            throw (ex);

        }

    }

    else if (this.UniqueName == "Note")

    {

        try

        {

            ((RadComboBox)o).DataSource = MYSOLUTION.DataLayer.GestioneAnomalie.GestioneAnomalieDataProvider.GetNote(e.Text);

        }

        catch (Exception ex)

        {

            throw (ex);

        }

    }

    ((RadComboBox)o).DataBind();

}

 

private void list_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)

{

    GridFilteringItem filterItem = (GridFilteringItem)((RadComboBox)o).NamingContainer;

    if ((this.UniqueName == "Index"))

    {

        //this is filtering for integer column type

        filterItem.FireCommandEvent("Filter"new Pair("EqualTo"this.UniqueName));

    }

    //filtering for string column type

    filterItem.FireCommandEvent("Filter"new Pair("Contains"this.UniqueName));

}       


RadGrid is in an ASCX file, it is placed in a RadAjaxPanel. A RadAjaxManager is also present down below the RadGrid, outside of the Ajax Panel.

<telerik:RadGrid

    ID="RadGridGestioneAnomalie"

    runat="server"

    AutoGenerateColumns="False"

    AllowFilteringByColumn="true"

    DataSourceID="LinqDataSourceAnomalie"

    GridLines="Both"

    Skin="WebBlue"

    AllowMultiRowSelection="True"

    AllowMultiRowEdit="True"   

    SortingSettings-SortedBackColor ="AliceBlue"

    SortingSettings-SortToolTip ="Ordina in base ai valori di questa colonna"

     

    ShowStatusBar="true"

    StatusBarSettings-LoadingText "Caricamento in corso"

    StatusBarSettings-ReadyText "Gestione Anomalie"

    PageSize="50"          

    PagerStyle-ForeColor="Black"

    PagerStyle-Position="TopAndBottom"  

    PagerStyle-AlwaysVisible="true"    

     

    EnableLinqExpressions="true"

    oninit="RadGridGestioneAnomalie_Init"

    onitemdatabound="RadGridGestioneAnomalie_ItemDataBound"

    onitemcommand="RadGridGestioneAnomalie_ItemCommand"

    oneditcommand="RadGridGestioneAnomalie_EditCommand"

    onitemcreated="RadGridGestioneAnomalie_ItemCreated"

    OnSortCommand="RadGridGestioneAnomalie_SortCommand"

    OnColumnCreating="RadGridGestioneAnomalie_ColumnCreating"

    oninsertcommand="RadGridGestioneAnomalie_InsertCommand"

    OnPreRender="RadGridGestioneAnomalie_PreRender"

    >

    <ExportSettings IgnorePaging="true" OpenInNewWindow="true" FileName="GestioneAnomalie" ExportOnlyData="true">

                    <Pdf FontType="Subset" PaperSize="Letter" AllowPrinting="true" />

                    <Excel Format="Html"  />

                    <Csv ColumnDelimiter="Comma" RowDelimiter="NewLine"  />

    </ExportSettings>

    <MasterTableView

     

        GroupLoadMode ="Client"

        HierarchyLoadMode="Client"      

                        CurrentResetPageIndexAction="SetPageIndexToFirst"         

        VirtualItemCount="50" 

        datakeynames="ID_Anomalia"

        datasourceid="LinqDataSourceAnomalie" 

        CommandItemDisplay="TopAndBottom" 

        GroupHeaderItemStyle-BackColor="LemonChiffon"

        AllowPaging ="true"

        AllowCustomSorting "true"

        AllowFilteringByColumn "true"

        AutoGenerateColumns="false"

        AllowSorting ="true"

        AllowNaturalSort="false" 

        PagerStyle-Mode="NextPrevNumericAndAdvanced"

        PagerStyle-BackColor="LightGray"

        PagerStyle-ForeColor="Black"

        PagerStyle-Position="TopAndBottom"

                                 

        Name="Anomalie"

        NoMasterRecordsText="Nessuna anomalia da mostrare"

        AllowAutomaticDeletes="True"

        AllowAutomaticUpdates="True" AllowAutomaticInserts="True"

        CanRetrieveAllData="True"                

        >


In the Page_Load, I pull out every column and later I put my personal dropdownfiltercolumn just for those column that has got particular UniqueName... here there's the code-behind :

protected void Page_Load(object sender, EventArgs e)

{

    EnsureUpdatePanelFixups();

 

    codiceProcesso = this.Page.Request.QueryString.Get(URLFactory.Param_ProcessoRilevatore);

 

    if (!(UserRole.isControlloQualita() || UserRole.isRilevatoreDelProcesso(codiceProcesso) || UserRole.isValidatoreDelProcesso(codiceProcesso))) 

    {

        // Per ora disabilito

        RadGridGestioneAnomalie.Visible = false;

        //RadGridTotaliOperazioni.Visible = false;

    }

 

     

    RadGridGestioneAnomalie.MasterTableView.IsItemInserted = false;

     

    LeggiParametriRicerca();

 

     

    #region Creazione Filtro DropDown

     

    if (!IsPostBack)

    {

        _rgSupporto = new List<GridColumn>();

        foreach (GridColumn colonna in RadGridGestioneAnomalie.MasterTableView.Columns)

        {

            _rgSupporto.Add(colonna);

        }

 

        RadGridGestioneAnomalie.MasterTableView.Columns.Clear();

 

        if (_rgSupporto.Count > 0)

        {

            foreach (GridColumn col in _rgSupporto)

            {

                if ((col.UniqueName == "Autore") || (col.UniqueName == "Note"))

                {

                    DropDownFilter gridColumn = new DropDownFilter();

                    this.RadGridGestioneAnomalie.MasterTableView.Columns.Add(gridColumn);

                    gridColumn.DataField = col.HeaderText;

                    gridColumn.HeaderText = col.HeaderText;

                }

                else

                    this.RadGridGestioneAnomalie.MasterTableView.Columns.Add(col);

            }

        }

    }


any help is appreciated

thanks
Giovanni

 

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 26 Oct 2010, 02:22 PM
Hello Giovanni,

I am sending you a simple example that is working as expected. Check it out and let me know if it helps.

Kind regards,
Pavlina
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
General Discussions
Asked by
Giovanni
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or