jqGrid empty data, and several methods to add new data

tags: jqGrid  

Generally speaking, there are three main methods for assigning values ​​to jqGrid.

Method 1. When initializing, directly pass in data
// dataSrc is the data source defined in the background or other ways
$("#xxx").jqGrid({
		data: dataSrc,
		datatype: 'local',
		editurl:'clientArray',
		cellEdit:true,
		cellsubmit:'clientArray',
		colNames: colObj[0],
		colModel: colObj[1],
		height:"150px",
		width:"850px",
		multiselect:false,
		regional: 'ja',
	});
Method 2. Through the setGridParam method

This method actually changes the controldata source, So you will needreloadGrid, The new information can be displayed on the page. The advantage is that if your grid is not only used for display, but also for modification and other operations, it is very suitable.

$("#xxx")
	.jqGrid("clearGridData")
	.jqGrid("setGridParam", {
		data:dataSrc // The data to be replaced dataSrc
	})
	.trigger("reloadGrid");  // reload displays new data
// $("#xxx").jqGrid("setGridParam", {data:dataSrc} can also be written as
// $("#xxx").setGridParam({data:dataSrc});
Method 3. Through the setGridParam method

The advantage of this method is that noreloadGrid, In fact, further speaking, it cannotreloadGrid, The data added after reload will disappear on the page, so if your operation needsreloadGridPlaces, this method is not recommended.

$("#xxx").jqGrid("clearGridData");
$("#xxx")[0].addJSONData(dataSrc);

Intelligent Recommendation

JQGrid two methods of data loading Json

Method One: once all the data is loaded to the front page and then paged Front page: Focus set in loadoncetrue, JsonReader of repeatitems set true, expressed JqGrid standard format, standard or not. B...

Two methods of setting grid data in Jqgrid-yellowcong

There are two ways to set data in the grid. One is through the addJSONData function. The advantage of this function is that you can directly modify the data globally without refreshing the table. The ...

jqGrid add data row addRowData slow solution

jqGrid is jQuery's grid widget, the function is relatively complete, and the api document is also complete.    At the beginning, test the insert data   100 pens 740ms very smooth 1,000 ...

More Recommendation

Several methods of data import

Pima Indians dataset Obtained from UCI, this is a data set for classification issues that primarily records medical data on whether Indians have diabetes in the last five years. (The data set file is ...

Several methods of data reading

Normal data reading Open() function Open file Parameter 'r' readable 'r' writable read() Reads the data of an open file as a string write() Save to an opened file as a string replace() replaces the da...

Several methods of submitting data

  Request page flow: enter URL, request controller -> return to view(Browser page = view), The browser parses the display page   Display page composed of html, css, js = view, view does n...

Several methods of data sorting

1. Sort directly through SQL statements, such as modifying the data set SQL statement as: 2. Realize the sorting effect by setting the advanced properties of the data column. Select the cell with the ...

The search that comes with jqgrid, using localized data search, supports all search methods that come with jqgrid

If the datatype of jqgrid's own search is non-local, then the search parameters will be passed in during the search, and then passed in to the address corresponding to the url for access. jqgrid itsel...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top