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

Easy grid auto-complete filter with local data?

5 Answers 428 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Casimodo
Top achievements
Rank 1
Casimodo asked on 29 Oct 2015, 05:14 PM

Hi,

until now I used the grid with odata-v4 data-sources. Auto-complete source configuration was easy: either omit the source and the Kendo grid fetches the data automatically or provide an odata data-source to be used for auto-complete values.

Today I have a scenario where I have local data and would like to filter the columns with auto-complete filters (row-filters).

From what I've read one has to set up the filter UI widget explicitly for each column. E.g.:

filterable: {
    ui: function (element) {
        element.kendoAutoComplete({
            dataSource: someDataSource,
            dataTextField: "Name"
        })
    }
}

This seems tedious because: 1) the data-source is the same as for the grid, 2) the field Name is the same as for the grid's column, 3) one has to have a reference to the data-source.

Is there a built-in mechanism to easily configure the filter to use auto-complete with the grid's own data-source and the grid column's field? After all, in the local data scenario, we would like to filter the stuff, that's ​in the grid already. So I wonder if we can avoid the ceremony.

Does an option like "filterable.autocomplete: true" maybe exist that I just overlooked?

Regards,
Kasimier Buchcik

5 Answers, 1 is accepted

Sort by
0
Casimodo
Top achievements
Rank 1
answered on 29 Oct 2015, 06:08 PM

I just learned that one only has to set filterable.dataSource in order to make the auto-complete work.

Unfortunately I also learned that sharing the grid's data-source with the filters does not work. So one has to programmatically update the filter's data when the grid's data changes.

Is there an option somewhere to make the filters share the grid's data-source?

Regards,

Kasimier Buchcik

0
Casimodo
Top achievements
Rank 1
answered on 29 Oct 2015, 06:22 PM
Jeez, can someone show me how to find the filter widgets programmatically in the grid, so I can refresh the data-sources of those ​widgets?
0
Boyan Dimitrov
Telerik team
answered on 02 Nov 2015, 10:05 AM

Hello Casimodo,

 

There is a specific if both Kendo UI AutoCompelte (filter) and Kendo UI Grid use same DataSource instance. If the Kendo UI Gid is filtered then in the AutoComplete widget will be shown only the filtered items. My suggestion is to use same array of data in order to initialize the Kendo UI DataSource for the Kendo UI Grid and the Kendo UI AutoComplete as shown in the http://dojo.telerik.com/IkagE example. 

 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Casimodo
Top achievements
Rank 1
answered on 13 Nov 2015, 08:51 PM
Yes. And now let's change the source data array. How to refresh the data-sources of th​e auto-complete ​widgets?
0
Boyan Dimitrov
Telerik team
answered on 17 Nov 2015, 12:41 PM

Hello Casimodo,

 

Once you have a reference to the AutoComplete widget itself you can use the dataSource property that will return the associated Kendo UI DataSource object. Once you have access to its DataSource you can use the Kendo UI DataSource API to get/modify the data and etc. 

 

In order to change the data array you can use the data method and pass the new array as parameter. Please refer to the examples in the article. 

 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Casimodo
Top achievements
Rank 1
Answers by
Casimodo
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or