I have a grid, when users click the button, it receives some parameters and updates the data source:
var grdUP = $("#weblogGrid").data("kendoGrid");
grdUP.dataSource.transport.options.read.url = url;
grdUP.dataSource.read();
It works great. new data is displayed in the grid. And the grid has another button that will export data to Excel. I use the code below (also tried the built-in button):
var grid = $("#weblogGrid").data("kendoGrid");
grid.saveAsExcel();
it actually exports the data to an excel file.
However, it always exports the source data to the grid, rather than updating the data user.
For example, when a grid is first displayed, it has 10 rows of data. After the upgrade, it has 5 rows of data. Now, if exported, it still exports 10 rows of data, although the data in the grid is different.
? , , - ?
===============================
, -
. , :
var url = '/WeblogReport/GetWebLogList?fromDate=' + fromDate + '&toDate=' + toDate;
var grdUP = $("#myGrid").data("kendoGrid");
grdUP.dataSource.transport.options.read.url = url;
grdUP.dataSource.read();
, :
....
$.ajax({
type: "GET",
dataType: "json",
url: "/WeblogReport/GetWebLogList",
data: { FromDate: fromDate, ToDate: toDate },
success: function (data) {
alert(data);
var grid = $("#myGrid").data("kendoGrid");
grid.dataSource.data(data);
grid.refresh();
}
});
- . - ?
.
Json.
success: function (data) {
var newdata = [{ "UserName": "username", "ClientIP": "1.1.1.1"}];
$("#myGrid").data("kendoGrid").dataSource.data(newdata);
$("#myGrid").data("kendoGrid").refresh();
}