In most applications, they get the initial data from the server and fill them in the grid. There are many formats of data sent from the server, and in this example, we will learn the data saved as JSON format.
$.ajax({
url: "/repo/grid/resource/data/orders.json",
dataType: 'text',
success: function (data) {
new DataLudi.DataLoader(dsMain).load("json", data, {
});
}
});
When load the data from the server to DataSet by calling DataLoader.load, all the existing data will be removed and new one will be filled in. However, if call load, the existing data can be modified or added depending on fillMode settings.
$.ajax({
url: "/repo/grid/resource/data/orders.csv",
dataType: 'text',
success: function (data) {
var row = grdMain.focusedIndex().rowIndex;
if (row < 0) row = 0;
new DataLudi.DataLoader(dsMain).load("csv", data, {
start: 1,
count: 500,
fillMode: 'insert', // 'insert', 'append', 'update', the default is 'set'
fillPos: row
});
}
});
If click the buttons below, it will load 5 rows and insert respectively in the current row location, or add after the last row, or modify 5 rows from the current row location.