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

Can transport data parameter be a function ?

1 Answer 121 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 31 May 2012, 01:39 PM
With this data source configuration .read() does not seem to be passing &group= and &subgroup= assignments to the server.  

var spaceSeasonDS =
new kendo.data.DataSource({
    transport: {
        read: {
            url: window.stpURL + "/SpaceAttribute",
            dataType: 'xml',
            data: {
                action: 'getSeasons',
                group: function(){
                    return spaceGroup.value()
                },
                subgroup: function(){
                    return spaceSubgroup.value()
                }
            },
            cache: false,
            complete: onReadComplete_Season
        }
    },
    schema: {
        type: "xml",
        data: "/TABLE/SEASONS",
        model: {
            fields: {
                item: "item/text()"
            }
        }
    },
    error: raiseXmlDsErrorWindow
});



Should 
data: {
    action: 'getSeasons',
    group: function(){
        return spaceGroup.value()
    },
    subgroup: function(){
        return spaceSubgroup.value()
    }
},

be this instead ?

data: function() {
return {
        action: 'getSeasons',
        group: spaceGroup.value(),
        subgroup: spaceSubgroup.value()
}},

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 04 Jun 2012, 06:25 AM
Hi Richard,

Yes, the group and subgroup parameters should not be a functions. Instead you could use one of the following approaches:
data: {
    foo: parseInt($("#test").val())
}
 
data: function () {
    return {
        foo: parseInt($("#test").val())
    }
}


Kind regards,
Alexander Valchev
the Telerik team
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
Richard
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or