hi.i am a newbie to javascript and webpages especially when it comes to grid i completely get out of my brain.so kindly please help me with a solution .
my problem
i am using jqgrid from guriddo in my web page.the problem is that when i set the datasource with nothing and input values to grid,the multiselect option of the grid works abnormally that when i click the checkbox on one row some other rows are also selected simultaneously.but when i load data using json or array,it works fine.
my code
<!DOCTYPE html>
<html lang=”en”>
<head>
<!– The jQuery library is a prerequisite for all jqSuite products –>
<script type=”text/ecmascript” src=”jquery.min.js”></script>
<!– We support more than 40 localizations –>
<script type=”text/ecmascript” src=”grid.locale-en.js”></script>
<!– This is the Javascript file of jqGrid –>
<script type=”text/ecmascript” src=”jquery.jqGrid.min.js”></script>
<!– This is the localization file of the grid controlling messages, labels, etc.
<!– A link to a jQuery UI ThemeRoller theme, more than 22 built-in and many more custom –>
<link rel=”stylesheet” type=”text/css” media=”screen” href=”jquery-ui.css” />
<!– The link to the CSS that the grid needs –>
<link rel=”stylesheet” type=”text/css” media=”screen” href=”ui.jqgrid.css” />
<meta charset=”utf-8″ />
<title>jqGrid Loading Data – Million Rows from a REST service</title>
</head>
<body><table id=”jqGrid”></table>
<script type=”text/javascript”>
var applicationGrid = $(“#jqGrid”),
myData = [];$(document).ready(function () {
$(“#jqGrid”).jqGrid({
url: ‘data.json’,
// we set the changes to be made at client side using predefined word clientArray
editurl: ‘clientArray’,
datatype: “json”,
colNames: [‘id’, ‘Product’, ‘qty’, ‘free’,’closed’],
colModel: [
{ name: ‘id’, hidden: true },
{ name: ‘Product’, width: 750 },
{ name: ‘Qty’, width: 200 ,align: ‘center’ },
{ name: ‘Free’, width: 200, align: ‘center’ },
{name:’closed’,index:’closed’,width:110,align:’center’,editable: true, formatter: ‘checkbox’,
edittype:”checkbox”,editoptions:{value:”Yes:No”,defaultValue:”Yes”},formatoptions: {disabled : false}},],
loadonce: true,
viewrecords: true,
width: 780,
height: 200,
rowNum: 10,
pager: “#jqGridPager”,
multiselect: true,});
$(‘#jqGrid’).navGrid(‘#jqGridPager’,
// the buttons to appear on the toolbar of the grid
{ edit: true, add: true, del: true, search: false, refresh: false, view: false, position: “left”,
cloneToTop: false },
// options for the Edit Dialog
{
editCaption: “The Edit Dialog”,
recreateForm: true,
checkOnUpdate : true,
checkOnSubmit : true,
closeAfterEdit: true,
errorTextFormat: function (data) {
return ‘Error: ‘ + data.responseText
}
},
// options for the Add Dialog
{
closeAfterAdd: true,
recreateForm: true,
errorTextFormat: function (data) {
return ‘Error: ‘ + data.responseText
}
},
// options for the Delete Dailog
{
errorTextFormat: function (data) {
return ‘Error: ‘ + data.responseText
}
});
});
$(window).on(“resize”, function () {
var newWidth = $(“#jqGrid”).closest(“.ui-jqgrid”).parent().width();
applicationGrid.jqGrid(“setGridWidth”, newWidth, true);
});function addRow(){
var row={id:”0″,Product:”MYPROduct”,Qty:”1″,Free:”1″};myData = [{id:”0″,Product:”MYPROduct”,Qty:”1″,Free:”1″}];
//jQuery(“#jqGrid”).addRowData(“3″, {Product:”Product”});
jQuery(“#jqGrid”).addRowData(“3″, {id:”0”,Product: $(“#Pro”).val(),Qty:$(“#qty”).val(),Free:”0″});}
</script>Product : <input type=”text” id=”Pro” size=”35%” >
Qty : <input type=”text” id=”qty” size =”15%”>
<input type=”submit” id =”btn” onclick=”addRow()” value=”Add” ></body>
</html>
i believe i will receive some guidance soon. advance thanks for help.
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top