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

Transport->Read->Data Parameter

1 Answer 641 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 03 Jun 2014, 07:22 PM
I'd like my "data" to be sending some of my MVVM model properties in the callback...

Example:
transport: {
            read: {
                url: "/RestApi/directory?format=json",
                dataType: "json",
                data: {
                    search: $model.get("searchterm")
                }
            }
        },

So I have a searchbox which is bound to $dataSource.read(); ...but regardless of the method I'm using (sync, fetch, read) that "data" never seems to be re-called.  Well...I mean I can't say that it's not working, maybe it is, and it's returning "", although I've valdiated my model has data in "searchterm"

Thoughts?

1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 05 Jun 2014, 01:51 PM
Hello Steve,

You can easily check the value of searchterm by using a function, for example: 
transport: {
    read: {
        url: "/RestApi/directory?format=json",
        dataType: "json",
        data: function(){
            console.log($model.get("searchterm"));
            return {
                search: $model.get("searchterm")
            };
        }
    }
},

You can also pass the additional data by calling the DataSource's read method: 
$dataSource.read({search: $model.searchitem})


Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Data Source
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
Alexander Popov
Telerik team
Share this question
or