JQGrid: добавить, редактировать форму, не отображаемая на кнопке Pager нажмитеJquery

Программирование на jquery
Ответить
Anonymous
 JQGrid: добавить, редактировать форму, не отображаемая на кнопке Pager нажмите

Сообщение Anonymous »

Я использую jquery 2.0.3 с jQuery-Migrate-1.4.1. После добавления jQuery Migrate JS, JQGrid Add, редактируйте кнопку Pager. Не отображая форму Add/Edit на кнопке Pager. /> Как я могу сделать кнопку JQGrid Pager для работы. Пожалуйста, предложите. < /P>
Найдите мой код ниже: < /p>














Test

















jQuery(document).ready(function() {

$('#from').val('');
$('#to').val('');
$('#sec').val('search');


$('#jqg_calltest').jqGrid('GridUnload');
$("#jqg_calltest").jqGrid({
//URL from which data should be requested
url: 'calltest_json.jsp',
postData: {
fromDate: function() { return jQuery("#from").val(); },
toDate: function() { return jQuery("#to").val(); },
section : function() { return jQuery("#sec").val(); },
sItem : function() { return jQuery('#sItem :selected').val();},
sItemTxt : function() { return jQuery("#sItemTxt").val(); },
locationid : function() { return jQuery("#sLocation").val(); },
testgroupid : function() { return jQuery("#sTestGroup").val(); },
},
//type of data
datatype: 'json',
//URL access method type
mtype: 'POST',
multiselect: true,
//columns names
colNames: ['Device ID', 'IMEI','Call Action','Phone Number', 'Calling To','Receiving From','Granularity','Periodicity','Mute Duration(in Mins)','Request Received','Device Status','Remarks', 'Location','Test Group','Restart', 'Stop'],
//columns model
colModel: [
{ name: 'devid', index: 'devid', align: 'center', width: 60, editable: true, sortable: false },
{ name: 'imei', index: 'imei', align: 'center', width: 120, sortable: false, editable: true},
{ name: 'call_action', index: 'call_action', align: 'center', width: 70, sortable: false, editable: true },
{ name: 'phone_number', index: 'phone_number', align: 'center', width: 100, sortable: false, editable: true },
{ name: 'call_number', index: 'call_number', align: 'center', width: 100, sortable: false, editable: true },
{ name: 'call_receive', index: 'call_receive', align: 'center', width: 100, sortable: false, editable: true },
{ name: 'granularity', index: 'granularity', align: 'center', width: 65, sortable: false, editable: true },
{ name: 'periodicity', index: 'periodicity', align: 'center', width: 65, sortable: false, editable: true },
{ name: 'duration', index: 'duration', align: 'center', width: 65, sortable: false, editable: true },
{ name: 'gcmstatus', index: 'gcmstatus', align: 'center', width: 80, sortable: false, editable: false,formatter: gcmStatusFormatter},
{ name: 'dstatus', index: 'dstatus', align: 'center', width: 90, sortable: false, editable: false,formatter: deviceStatusFormatter},
{ name: 'remarks', index: 'remarks', align: 'center', width: 230, sortable: false, editable: false, formatter: remarksFormatter},
{ name: 'LID', index: 'LID', align: 'center', width: 80, sortable: false, editable: false, formatter: remarksFormatter},
{ name: 'TGID', index: 'TGID', align: 'center', width: 80, sortable: false, editable: false, formatter: remarksFormatter},
{ name: 'restart', index: 'restart', align: 'center', width: 80, sortable: false, editable: false, formatter: restartBtnFormatter },
{ name: 'stop', index: 'stop', align: 'center', width: 80, sortable: false, editable: false, formatter: stopBtnFormatter }

],

//pager for grid
pager: $('#jqg_calltestpager'),

//number of rows per page
rowNum: 100,
rowList: [10,25,40,75,100, 500, 1000, 1500],
sortname: 'DeviceID',
sortorder: 'ASC',
autowidth: true,
shrinkToFit: false,
viewrecords: true,
loadonce: false,
rownumbers: true,
rownumWidth: 40,
height: 600,
//width: 1200,
caption: "  Call Test Data",
emptyrecords: 'No data to display!',
loadtext: 'Loading...',
// autoid : true,

afterInsertRow: function (rowid, data) {
// To Restart Row Test
var grid = $("#jqg_calltest");
var iCol = getColumnIndexByName (grid, "restart");
$("td:eq("+iCol+")","#"+rowid).click(function () {
//$("td:eq(10)","#"+rowid).click(function () {
var strdata ="";
var rowData =jQuery('#jqg_calltest').jqGrid("getRowData", rowid);

strdata = strdata +rowData.devid+"&";
strdata = strdata + rowData.imei+"&";
strdata = strdata +rowData.call_action+"&";
strdata = strdata + rowData.call_number+"&";
strdata = strdata + rowData.call_receive+"&";
strdata = strdata + ",";
$.ajax({
type: "POST",
url: "SendCallMessage",
dataType:"json",
data:{
calldata: strdata
},
success: function(response, textStatus, jqXHR) {
// display an success message if needed
alert("Call Test for Device ID: "+rowData.devid +" has been Restarted");
},
error: function(jqXHR, textStatus, errorThrown) {
// display an error message in any way
alert("ERROR Restarting Call Test!!!");
}
});
});

//To Stop Row Test
iCol = getColumnIndexByName (grid, "stop");
$("td:eq("+iCol+")","#"+rowid).click(function () {
//$("td:eq(11)","#"+rowid).click(function () {
var strdata ="";
var rowData =jQuery('#jqg_calltest').jqGrid("getRowData", rowid);
strdata = strdata +rowData.devid+"&";
strdata = strdata + rowData.imei;
strdata = strdata + ",";
//alert(strdata);
$.ajax({
type: "POST",
url: "SendStopCallMessage",
dataType:"json",
data:{
stoppingdata: strdata
},

success: function(response, textStatus, jqXHR) {
// display an success message if needed
alert("Call Test for Device ID: "+rowData.devid +" has been stopped");
},
error: function(jqXHR, textStatus, errorThrown) {
// display an error message in any way
alert("ERROR Stopping Call Test!!!");
}
});
});
},
loadComplete : function(){
var selRowIds = jQuery("#jqg_calltest").jqGrid('getGridParam', 'selarrrow');
totalcount = 0;
failcount = 0;
for(var i=0;i=0){
failcount++;
}
}
$("label[for='lblCount']").text(failcount + '/' + totalcount);
$("#jqg_calltest").jqGrid("setLabel", "rn", "RN");
},
onSelectRow: function (id, status) {
// var selRowId = jQuery("#jqg_calltest").jqGrid ('getGridParam', 'selrow');
var celValue = jQuery("#jqg_calltest").jqGrid ('getCell', id, 'dstatus');
if (status) { // selected
if(celValue.indexOf("FAIL")>=0){
failcount++;
}
totalcount ++;
}else{
if(celValue.indexOf("FAIL")>=0){
failcount--;
}
totalcount --;
}
$("label[for='lblCount']").text(failcount + '/' + totalcount);
},
onSelectAll:function(id,status){
if(status){
totalcount = id.length;
failcount = 0;
for(i=0;i=0){
failcount++;
}
}
}else{
totalcount = 0;
failcount = 0;
}

$("label[for='lblCount']").text(failcount + '/' + totalcount);
}
});
jQuery("#jqg_calltest").jqGrid('navGrid', '#jqg_calltestpager', {
edit : true, add : true, del : true,search : false, refresh:false, refreshstate: "current"},
//edit options
{
beforeShowForm: function(form) {
$('#tr_imei', form).hide();
$('#tr_devid', form).hide();
//$('#tr_imei', formid).attr("disabled", "disabled");
},

afterSubmit: function (response) {
if (response.status == 200) {
$(this).jqGrid('setGridParam',
{ datatype: 'json' }).trigger('reloadGrid', [{current:true}]);//Reloads the grid after edit
//failcount = 0;
//totalcount = 0;
return [true, ''];
}
else {
$(this).jqGrid('setGridParam',
{ datatype: 'json' }).trigger('reloadGrid', [{current:true}]); //Reloads the grid after edit
//failcount = 0;
//totalcount = 0;
return [false, response.responseText];
//Captures and displays the response text on th Edit window
}

},

onclickSubmit: function(rp_ge, postdata) {
rp_ge.url = 'calltest_json.jsp?section=edit';
},

closeOnEscape: true,//Closes the popup on pressing escape key
reloadAfterEdit: true,
closeAfterEdit: true,
drag: true,
},
//add options
{
afterShowForm: function (form) {
$('#tr_imei', form).show();
$('#tr_devid', form).show();
},
afterSubmit: function (response) {
var myInfo = ''+
'' +
response.responseText +
'',
$infoTr = $("#TblGrid_" + $.jgrid.jqID(this.id) + ">tbody>tr.tinfo"),
$infoTd = $infoTr.children("td.topinfo");
$infoTd.html(myInfo);
$infoTr.show();

// display status message to 3 sec only
setTimeout(function () {
$infoTr.slideUp("slow");
}, 5000);
//failcount = 0;
//totalcount = 0;
return [true, "", ""]; // response should be interpreted as successful
},
errorTextFormat: function (response) {
var txt = response.statusText;
var restxt = response.responseText;
if(response.status == 406){
return '' +
"Device ID Already Exists";
}
else {
return '' +
"IMEI Already Exists";
}

},

onclickSubmit: function(rp_ge, postdata) {
var totalrecords = $('#jqg_calltest').getGridParam("records") ;

rp_ge.url = 'calltest_json.jsp?section=add&devidmax='+ totalrecords;
},
closeOnEscape: true,//Closes the popup on pressing escape key
reloadAfterSubmit: true,
closeAfterSubmit: true,
closeAfterAdd: true,
drag: true,
},
//del options
{

beforeShowForm: function ($form) {
var rowids = jQuery('#jqg_calltest').jqGrid('getGridParam', 'selarrrow');

$("td.delmsg", $form[0]).html("Delete selected Record with Device ID: " +
rowids + "
?");
},
afterSubmit: function (response, postdata) {
if (response.status == 200) {
$('#jqg_calltest').jqGrid('setGridParam',
{ datatype: 'json' }).trigger('reloadGrid', [{current:true}]);//Reloads the grid after edit
//failcount = 0;
// totalcount = 0;
return [true, ''];
}
else {
$('#jqg_calltest').jqGrid('setGridParam',
{ datatype: 'json' }).trigger('reloadGrid', [{current:true}]); //Reloads the grid after edit
// failcount = 0;
//totalcount = 0;
return [false, response.responseText];
//Captures and displays the response text on th Edit window
}
},
onclickSubmit: function(rp_ge, postdata) {

var selIds = jQuery("#jqg_calltest").jqGrid('getGridParam', 'selarrrow');
var strdata ='';
for(var i = 0; i < selIds.length; i++){
var rowData =jQuery("#jqg_calltest").jqGrid("getRowData", selIds);

strdata = strdata + rowData.imei;
strdata = strdata + ",";
}
rp_ge.url = 'calltest_json.jsp?section=delete&imei='+ strdata;
},
closeOnEscape: true,
closeAfterDelete: true,
reloadAfterDelete: true,
},
//search options
{
},
// veiw options
{
width: 500, height: 'auto',
closeOnEscape: true
});
});

var failcount = 0;
var totalcount = 0;

function restartBtnFormatter(cellvalue, options, rowObject) {
return "";
}

function stopBtnFormatter(cellvalue, options, rowObject) {
return "";
}

function gcmStatusFormatter(cellvalue, options, rowObject) {
if(cellvalue == "YES")
return ''+cellvalue+'
'; else if(cellvalue == "NA")
return ''+cellvalue+'
'; else
return ''+cellvalue+'';
}

function deviceStatusFormatter(cellvalue, options, rowObject) {
if(cellvalue == "CONNECTED")
return ''+cellvalue+'
'; else if(cellvalue == "NA")
return ''+cellvalue+'
';
else
{
return ''+cellvalue+'';
}
}

function remarksFormatter(cellvalue, options, rowObject) {
return ''+cellvalue+'';
}

$(function(){
getColumnIndexByName = function (grid, columnName) {
var cm = grid.jqGrid('getGridParam', 'colModel'), i, l = cm.length;
for (i = 0; i < l; i++) {
if (cm.name === columnName) {
return i; // return the index
}
}
return -1;
}
});

function clearResults() {
//debugger;
//failcount = 0;
//totalcount = 0;
$('form').submit(function (e) {
e.preventDefault();
});

var selIds = jQuery("#jqg_calltest").jqGrid('getGridParam', 'selarrrow');
if (selIds.length

Подробнее здесь: https://stackoverflow.com/questions/379 ... tton-click
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Jquery»