<script>
$ (document). Ready (function ()
{
Initplsflist ();
});
Initialize Grid list
function Initplsflist () {
Cache table column array, key is the name of the page element, value corresponds to the field in the database
var cellarray = new Array ();
cellarray["ZoneID"] = "zone_id";
cellarray["FACTORPG"] = "FACTOR_PG";
cellarray["FACTORQG"] = "FACTOR_QG";
cellarray["FACTORPL"] = "FACTOR_PL";
cellarray["FACTORQL"] = "FACTOR_QL";
cellarray["valid"] = "valid";
var Caseid = ' ${caseid} ';
$ ("#plsfList"). Jqgrid ({
URL: "<c:url value= '/lfc/powerlsfactor/querydata?caseid=" +caseid+ "'/>",
DataType: "JSON",
Mtype: "POST",
Height: "Auto",
Width: "Auto",
colnames:[
' ID ',
"<fmt:message key= ' case.valid '/>",
"<fmt:message key= ' zone '/>",
"<fmt:message key= ' pasf '/>",
"<fmt:message key= ' pisf '/>",
"<fmt:message key= ' lasf '/>",
"<fmt:message key= ' lisf '/>",
' Modeid '
],
colmodel:[
{name: ' id ', index: ' id ', width:100,hidden:true},
{name: ' valid ', index: ' Valid ', Width:100,editable:true,
Formatter:formatvalid,
Editable:true,edittype: ' checkbox ',
Editoptions:{value: ' 1:0 ', defaultvalue: ' 1 '}
},
{name: ' ZoneName ', index: ' ZoneName ', width:150,editable:true},
{name: ' FACTORPG ', index: ' FACTORPG ', width:100,editable:true},
{name: ' FACTORQG ', index: ' FACTORQG ', width:100,editable:true},
{name: ' FACTORPL ', index: ' FACTORPL ', width:100,editable:true},
{name: ' FACTORQL ', index: ' FACTORQL ', width:100,editable:true},
{name: ' Caseid ', index: ' Caseid ', width:100,hidden:true},
],
Rownum:10,
ROWLIST:[10,20,30],
Pager: ',
Celledit:true,
Viewrecords:true,
Jsonreader: {repeatitems:false, ID: "ID"},
Viewsortcols:[false, ' horizontal ', false],
Sortable:false,
SortOrder: "ASC",
Sortname: "id",
Multiselect:true,
Cellurl: "<c:url value= '/lfc/powerlsfactor/save '/>",
Cellsubmit: ' Remote ',
Gridcomplete:function () {
var $selecAll = $ ("#cb_plsfList");
var cb_title = "<fmt:message key= ' select.all ' bundle= ' ${commonresources} '/>";
if ($SELECALL) {
$selecAll. attr ("title", Cb_title);
}
Set all checkbox title
var rowids = jQuery ("#plsfList"). Jqgrid (' Getdataids ');
for (var k=0; k<rowids.length; k++) {
var currowdata = jQuery ("#plsfList"). Jqgrid (' GetRowData ', rowids[k]);
var Curchk = $ ("#" +rowids[k]+ ""). Find (": checkbox");
Curchk.attr (' title ', Currowdata.modename); Assigning additional property values to a checkbox
}
},
Onsortcol:function (Index,icol,sortorder) {
return false;
},
Ondblclickrow:function (rowid,irow,icol,e) {
/*var $plsfList = $ ("#plsfList");
if (Isrowneedsave ($plsfList)) {
ShowMessage ("Please save First");
}else{
$ ("#operate"). Val ("Update");
Newrowid = rowID;
$plsfList. Setgridparam ({celledit:false});
$plsfList. Jqgrid (' Editrow ', rowid, true);
Make sure the button is available
$ ("#confirm_btn"). attr ("disabled", false);
}*/
},
Beforesubmitcell:function (ROWID, Cellname, value, IRow, Icol) {
Blocking method before column commits
var $plsfList = $ ("#plsfList");
var $editUrl = ' <c:url value= '/lfc/powerlsfactor/save '/> ';
Sets the URL for the column submission. Updatecellname: The name of the column to edit; Updatecellvalue: is the edited value
$EDITURL = Addparamtourl ($editUrl, ' updatecellname ', Icol = 3? cellarray[' ZoneID ']: cellarray[cellname]);
$EDITURL = Addparamtourl ($editUrl, ' updatecellvalue ', Icol = 3? $ ("#zone_id"). Val (): value);
New set Cellurl value for Jqgrid
$plsfList. Setgridparam ({cellurl: $editUrl});
return false;
},
Aftereditcell:function (ROWID, Cellname, value, IRow, Icol) {
When dynamically modifying lie, when the column becomes modifiable, add a button to the column, and the element in the column is not editable, click the button to eject a modal window, you can select elements, assign to grid in the current edit column in one-line form field.
$ ("#" +rowid+ "input[type= ' checkbox ']"). attr ("checked", value = = "<fmt:message key=" Case.valid '/> '? true:false) ;
if (icol==3) {
$ ("#irowNum"). Val (ROWID);
var $data = $ ("#" +rowid + ">TD"); Gets all the TD elements in this line, that is: get all child elements
$zoneInput = $data. Find ("input")-eq ("1");
$zoneInput. CSS ("width", "100px");
$zoneInput. attr ("Disabled", true);
$zoneInput. After ("<input type= ' button ' value= ' select ' onclick= ' Fncalldialogforeidt () '/>");
}
}
});
Grid to add a new line
var Newrowid;
function AddRow ()
{
$ ("#operate"). Val ("");
var Selectedid = $ ("#plsfList"). Jqgrid ("Getgridparam", "Selrow");
var ids = jQuery ("#plsfList"). Jqgrid (' Getdataids ');
Get current maximum line number (data number)
var rowid = Math.max.apply (math,ids);
Get the line number of the newly added row (data number)
Newrowid = rowid+1;
var DataRow = {
ID: "",
Valid: "",
ZoneID: ',
FACTORPG: ',
FACTORQG: ',
FACTORPL: ',
FACTORQL: ',
Caseid: '
};
Inserts the newly added row into the first column
$ ("#plsfList"). Jqgrid ("Addrowdata", Newrowid, DataRow, "a");
Set Grid cell not editable
$ ("#plsfList"). Setgridparam ({celledit:false});
Set grid cells to edit
$ (' #plsfList '). Jqgrid (' Editrow ', Newrowid, false);
Make sure the button is available
$ ("#confirm_btn"). attr ("disabled", false);
Add a selection button to the column added
var $zoneInput = $ ("#" +newrowid+ "_zonename");
$zoneInput. attr ("Disabled", true). CSS ("width", 100);
$zoneInput. After ("<input type= ' button ' value= ' select ' onclick= ' Fncalldialogforeidt () '/>");
}
function Insertplsf () {
var $plsfList = $ ("#plsfList");
var $operate = $ ("#operate"). Val ();
Set grid cells to edit
$plsfList. Setgridparam ({celledit:true});
Set grid line not editable
$plsfList. Jqgrid (' Editrow ', Newrowid, false);
The URL of the mosaic request
var url = ' <%=basePath%> ' + "/lfc/powerlsfactor/save";
var $params = $plsfList. Find ("input[id^=" +newrowid+ "]");
var $check _val = $params. EQ (0). Is (': Checked ')? 1:0;
url = addparamtourl (URL, ' valid ', $check _val);
url = addparamtourl (URL, ' ZoneID ', $ ("#zone_id"). Val ());
url = addparamtourl (URL, ' FACTORPG ', $params. EQ (2). Val ());
url = addparamtourl (URL, ' FACTORQG ', $params. EQ (3). Val ());
url = addparamtourl (URL, ' factorpl ', $params. EQ (4). Val ());
url = addparamtourl (URL, ' FACTORQL ', $params. EQ (5). Val ());
var $caseID = $ ("#caseID"). Val ();
url = addparamtourl (URL, ' Caseid ', $caseID);
$.ajax ({url:url,type: "post", timeout:5000,
Success:function (data) {
ShowMessage (data);
Reloadgrid ();
}
});
Initializes the newly added line number to empty
Newrowid = ';
OK button not available
$ ("#confirm_btn"). attr ("Disabled", true);
}
Format Zone column output content
function Formatzone (cellvalue, Options, Rowobject) {
if (Cellvalue = = 0) {
return 0;
}else if (Cellvalue = = 1) {
return 1;
}else if (Cellvalue = = 2) {
return 2;
}else{
return 3;
}
}
function Isrowneedsave ($jqgrid) {
var $editTr = $jqgrid. Find ("tr[editable=1]");
var flag = false;
if ($editTr && $editTr. length > 0) {
Flag = true;
}
return flag;
}
function Cancel () {
Reloadgrid ();
OK button not available
$ ("#confirm_btn"). attr ("Disabled", true);
Set grid cells to edit
$ ("#plsfList"). Setgridparam ({celledit:true});
Set grid cells to edit
$ (' #plsfList '). Jqgrid (' Editrow ', Newrowid, true);
}
function Fncalldialogforeidt () {
Get Current line number (data number)
var returnvalue = "";
returnvalue = window.showModalDialog ("<c:url value= '/element/zone/query?caseid=" +$ ("#caseID"). Val () + "'/>", window, "");
if (returnvalue== "" | | Returnvalue==null)
Return
var $plsfList = $ ("#plsfList");
var $params = $plsfList. Find ("input[id$= ' ZoneName ')");
var names = Returnvalue.split (",");
$params. EQ (0). val (Names[1]);
$ ("#zone_id"). Val (Names[0]);
}