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

radgrid filter with datasource

2 Answers 481 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Luigi Bardetti
Top achievements
Rank 1
Luigi Bardetti asked on 07 Jul 2015, 08:30 AM

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 Answers, 1 is accepted

Sort by
0
Luigi Bardetti
Top achievements
Rank 1
answered on 07 Jul 2015, 08:50 AM
is it possibile to pass impagination and sort parameters to sqldatasource?
0
Eyup
Telerik team
answered on 10 Jul 2015, 06:38 AM
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
Tags
Grid
Asked by
Luigi Bardetti
Top achievements
Rank 1
Answers by
Luigi Bardetti
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or