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

Server Filtering with Shared DataSource

3 Answers 292 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 2
Iron
Veteran
Iron
Richard asked on 15 Feb 2018, 02:51 PM

Hi,

I'm trying to add server filtering to the shared data source example on the demo site (Shared DataSource)

How can I add the .ServerFiltering(true) option to either the AutoComplete control or the DataSource ? 

Thanks,

Richard 

 

@(Html.Kendo().DataSource<Kendo.Mvc.Examples.Models.ProductViewModel>()
    .Name("dataSource1")
    .Ajax(dataSource => dataSource
       .Read(read => read.Action("Products_Read", "DataSource"))
       .ServerOperation(true)
     -->> .ServerFiltering(true) << --
    )
)
 
 
@(Html.Kendo().AutoComplete()
    .Name("autoComplete")
    .DataTextField("ProductName")
    .Filter(FilterType.Contains)
    .MinLength(2)
    .DataSource("dataSource1") -->> .ServerFiltering(true) <--
)

3 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 20 Feb 2018, 10:10 AM
Hi Richard,

I am attaching an ASP.NET MVC solution, where a similar scenario to the one described is demonstrated (Enable server filtering for a shared DataSource).

Server-filtering is based on the filtering capability of the DataSource component. When an Ajax binding is used, all of the server operations for server, paging, sorting and grouping are being performed on the server, unless the ServerOperation() option is set to false.

In case you would like to explicitly set the ServerFiltering option, then a Custom DataSource has to be used:
@(Html.Kendo().DataSource<TelerikMvcAppSharedDataSource.Models.ProductViewModel>()
.Name("dataSource1"
.Custom(dataSource => dataSource
.Type("aspnetmvc-ajax")
.ServerFiltering(true)
.Transport(m => m.Read("GetProducts", "Home"))
.Schema(m => m.Data("Data").Total("Total"))
)
)
  
@(Html.Kendo().DropDownList()
  .Name("SecurityQuestionId1")
  .HtmlAttributes(new { @class = "sq-control form-control" })
  .DataTextField("ProductName")
  .DataValueField("ProductID")
  .DataSource("dataSource1")
  .AutoBind(true)
  .Value("20")
  .Filter(FilterType.Contains)
)


Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Richard
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 20 Feb 2018, 12:33 PM

Thank you Dimitar, that's really helped me. 

I have one last follow up question. I'm adding this control to a toolbar so I add a template to the tool bar and update with JavaScript. Can you tell me how to correctly set the the DataSource ? the below doesn't work. 

Thanks,
Richard

<script>
    $(document).ready(function () {
        $("#GridSearchBox").kendoAutoComplete({                   
            placeholder: "Search Grid...",
            dataTextField: "Name",
            minlength: "3",
            datasource: 'GridDataSource'
        });
    });
</script>

 

 

0
Richard
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 20 Feb 2018, 01:11 PM
Update, I found what I was looking for, the BindTo param. 

 

 
 <script>
    $(document).ready(function () {
        $("#GridSearchBox").kendoAutoComplete({                   
            placeholder: "Search Grid...",
            dataTextField: "Name",
            minlength: "3",
            bindto: 'GridDataSource'
        });
    });
</script>
Tags
AutoComplete
Asked by
Richard
Top achievements
Rank 2
Iron
Veteran
Iron
Answers by
Dimitar
Telerik team
Richard
Top achievements
Rank 2
Iron
Veteran
Iron
Share this question
or