Created
October 30, 2015 14:57
-
-
Save milannankov/baea0321be100668a95d to your computer and use it in GitHub Desktop.
Code Bites: Parsing Server Response With Kendo DataSource
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var viewModel = kendo.observable({ | |
users: new kendo.data.DataSource({ | |
transport: { | |
read: { | |
url: "http://localhost:10243/api/users", | |
type: "GET", | |
dataType: "json" | |
} | |
}, | |
schema: { | |
parse: function (response) { | |
// store transformed user data | |
var usersData = []; | |
for (var i = 0; i < response.length; i++) { | |
// create new user object | |
var user = { | |
id: response[i].Id, | |
fullname: response[i].FirstName + " " + response[i].LastName, // combine first name and last name | |
email: response[i].Email | |
}; | |
usersData.push(user); | |
} | |
return usersData; | |
} | |
}, | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment