radgrid filter with datasource

3 posts, 0 answers
  1. Luigi Bardetti
    Luigi Bardetti avatar
    12 posts
    Member since:
    Oct 2007

    Posted 07 Jul 2015 Link to this post

    hi,

    i am using your telerik datagrid, every thing works fine but i need to pass the filter values to the sql datasource (or a simple objectdatasource).

    Can you help me?

    thanks!

    <asp:SqlDataSource ID="SqlDataSource1"
                        ConnectionString="***"
                        ProviderName="System.Data.OracleClient" SelectCommand="select * from MAINITEMS" runat="server">
     </asp:SqlDataSource>
     
    <telerik:RadGrid runat="server" ID="RadGrid1" Width="99%" Height="600px"
                        DataSourceID="SqlDataSource1"
                        AllowFilteringByColumn="True" AllowSorting="True"
                        ShowFooter="False" ShowHeader="True"
                        OnPreRender="RadGrid1_OnPreRender"
                        AllowAutomaticDeletes="False"
                        AllowAutomaticUpdates="False"
                        AllowAutomaticInserts="False"
                        AutoGenerateColumns="True"
                        AllowPaging="True" PageSize="30"
                        ShowGroupPanel="True" >
                 
                            <GroupingSettings CaseSensitive="false" ShowUnGroupButton="true"></GroupingSettings>
                            <%--configurazione per spostare le colonne--%>
                            <ClientSettings AllowColumnsReorder="true" ReorderColumnsOnClient="true" AllowKeyboardNavigation="true" AllowDragToGroup="True">
                                <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true"></Scrolling>
                            </ClientSettings>
     
                            <MasterTableView CommandItemDisplay="None" DataKeyNames="ID" AllowFilteringByColumn="True" >
                            </MasterTableView>
     
                    </telerik:RadGrid>

  2. Luigi Bardetti
    Luigi Bardetti avatar
    12 posts
    Member since:
    Oct 2007

    Posted 07 Jul 2015 in reply to Luigi Bardetti Link to this post

    is it possibile to pass impagination and sort parameters to sqldatasource?
  3. Eyup
    Admin
    Eyup avatar
    3795 posts

    Posted 10 Jul 2015 Link to this post

    Hello Luigi,

    RadGrid provides advanced databinding methods, which automatically handle the complex grid operations such as Inserting, Deleting, Updating, Hierarchy relations, Grouping, Exporting, Paging, Sorting, Filtering, etc. require accommodating appropriate database operations:
    Declarative DataSource
    Programmatic Data Binding


    If you want to define initial Sorting expression, you can use the following approach:
    <SortExpressions>
        <telerik:GridSortExpression FieldName="Freight" SortOrder="Descending" />
    </SortExpressions>

    In case you want to apply initial filter, you can use the FireCommandEvent method:
    http://www.telerik.com/help/aspnet-ajax/grid-fire-command-event-from-code.html


    For example:
    Copy Code
    Copy Code
    Copy Code
    Copy Code
    protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GridFilteringItem filterItem = RadGrid1.MasterTableView.GetItems(
                 GridItemType.FilteringItem)[0] as GridFilteringItem;
      
            GridColumn col = RadGrid1.MasterTableView.GetColumn("ShipName");
            col.CurrentFilterValue = "Success";
            filterItem.FireCommandEvent("Filter", new Pair("StartsWith", "ShipName"));
        }
    }

    Hope this helps.

    Regards,
    Eyup
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top