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

Calling dataSource.parameterMap function from outside

1 Answer 163 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Olli
Top achievements
Rank 1
Olli asked on 10 Sep 2013, 11:59 AM
Hi,

I have four multiSelects that contain hierarchical data so that  level 4 item knows its parents in level3, level2, and level1 and so on.

Each of multiselects has their own remote dataSource. Everytime when a dataSource requests for items from server the parameterMap function reads selections from its "parent" multiselects and puts them as parameters to request. I also attach the multiSelect's search text as parameter to the request.

Like this way:
$("#level3-multiselect").kendoMultiSelect({
        autoBind: false,
        dataTextField: "name",
        dataValueField: "id",
        dataSource: {
            serverFiltering: true,
            transport: {
                dataType: "jsonp",
                read: baseurl: 'http://myurl'
                parameterMap: function(options, operation) {                   
                    var _name = "";                   
                    if ('filter' in options && options.filter.filters.length > 0) {
                        _name = options.filter.filters[0].value;
                    }
                    return {
                        level1ids: getLevel1Ids().join(),
                        level2ids: getLevel2Ids().join(),                       
                        name: _name
                    }                      
                }
            },
            schema: {
                data: "items"
            }
        }
    });

My problem is that the multiselects parameterMap function is fired only when I change the text in that particular box. In additon to that, I would also like to run parameterMap function every time when a parent-level selection changes. I know there is a 'selected' event in multiSelect widget, but how can I call parameterMap function of a multiSelects dataSource?

Olli

1 Answer, 1 is accepted

Sort by
0
Olli
Top achievements
Rank 1
answered on 11 Sep 2013, 10:13 AM
Figured out the solution with dataSource.query() method that is called for all the sublevel multiSelects when a multiSelect's dataBound event is raised. 
Tags
Data Source
Asked by
Olli
Top achievements
Rank 1
Answers by
Olli
Top achievements
Rank 1
Share this question
or