SMART datagrid v.1 > Examples

Back  Forward

Load XML Data  Example

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 XML format. 

Code -1
    $.ajax({
    	url: "/repo/grid/resource/data/orders.xml",
    	dataType: 'text',
    	success: function (data) {
            new DataLudi.DataLoader(dsMain).load("xml", data, {
            });
    	}
    });
Grid - 1
rows

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. 

Code -2
    $.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 10 rows and insert respectively in the current row location, or add after the last row, or modify 10 rows from the current row location. 

Grid - 2
rows

View Source JSP 

See Also
GridView
Examples
Load JSON Data
Load CSV Data