Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Add row and immediately inline edit
12/08/2010
21:55
Avatar
JOttinger
New Member
Members
Forum Posts: 1
Member Since:
12/08/2010
sp_UserOfflineSmall Offline

I'm not sure why, in my code below, I can't get the inline editing of a row to work after I've just added it.
 When I click on my #addrow button, a new row is added, but the code to edit that same row doesn't work.
If I manually select it and edit it, it works.

I've been stuck on this issue for a couple days, so any help would be appreciated :)

$(document).ready(function(){
	var lastsel=0;
	$("#datagrid").jqGrid({
		url:"/?mailer/jobsajax&getdata=1",
		datatype: "json",
		height: 200,
		width: 680,
		shrinkToFit: false,
	   	colNames:['ID','Job Name','Process','Disabled','Description', 'Frequency', 'From Email', 'From Name', 'Reply Email', 'Subject', 'Content URL', 'Restricted', 'Last Run'],
	   	colModel:[
	   	    {name:'id', index:'id', hidden:true},
	   		{name:'jobname', index:'jobname', width:200, editable:true, editoptions:{size:"35",maxlength:"50"}},
	   		{name:'process', index:'process', width:80, sortable:true, editable:true, edittype:"select", editoptions:{value:"start:start;active:active;stopped:stopped"}},	
	   		{name:'disabled', index:'disabled', width:60, sortable:true, editable:true, edittype:"checkbox", editoptions:{value:"Yes:No"}},
	   		{name:'description', index:'description', width:250, sortable:true,editable:true, edittype:"textarea", editoptions:{rows:"2",cols:"35"}},
	   		{name:'frequency', index:'frequency', width:80, sortable:true, editable:true, edittype:"select", editoptions:{value:"manual:manual;daily:daily;weekly:weekly;biweekly:biweekly;monthly:monthly;annually:annually"}},
	   		{name:'fromemail', index:'fromemail', width:150, sortable:true, editable:true, editoptions:{size:"25",maxlength:"250"}},		
	   		{name:'fromname', index:'fromname', width:150, sortable:true, editable:true, editoptions:{size:"25",maxlength:"250"}},		
	   		{name:'replyemail', index:'replyemail', width:150, sortable:true, editable:true, editoptions:{size:"25",maxlength:"250"}},		
	   		{name:'subject', index:'subject', width:150, sortable:true, editable:true, editoptions:{size:"25",maxlength:"250"}},		
	   		{name:'contenturl', index:'contenturl', width:150, sortable:true, editable:true, editoptions:{size:"25",maxlength:"50"}},
	   		{name:'restricted', index:'restricted', width:60, sortable:true, editable:true, edittype:"checkbox", editoptions:{value:"Yes:No"}},
	   		{name:'lastrun', index:'lastrun', width:70, sortable:true, editable:false}	
	   	],
	   	onSelectRow: function(id){
			lastsel=id;
		},
		rowNum:50,
		rowTotal: 2000,
		rowList : [20,30,50],
		loadonce:true,
		mtype: "GET",
		rownumbers: false,
		rownumWidth: 40,
		gridview: true,
		pager: '#pager',
		sortname: 'id',
		viewrecords: true,
		sortorder: "desc", 
		editurl: "/?mailer/jobsajax",
		caption: "Email Job List",

	});
	$("#datagrid").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false}); 
	$("#editrow").click( function() {
		if(lastsel!=0){
			cursel=lastsel
			$("#datagrid").jqGrid('editRow',cursel);
			$(this).attr("disabled",true); 
			$("#saverow").attr("disabled",false);
			$("#cancel").attr("disabled",false);
		}
	});
	$("#saverow").click( function() {
		$("#datagrid").jqGrid('saveRow',cursel);
		$(this).attr("disabled",true); 
		$("#editrow").attr("disabled",false); 
		$("#addrow").attr("disabled",false); 
	});
	$("#cancel").click( function() {
		$("#datagrid").jqGrid('restoreRow',cursel);
		$(this).attr("disabled",true); 
		$("#editrow").attr("disabled",false);
		$("#addrow").attr("disabled",false); 
	});
	$("#addrow").click( function() {
		emptyItem=[{id:"",jobname:"",process:"stopped",disabled:"No",description:"",frequency:"manual",fromemail:"",fromname:"",replyemail:"",subject:"",contenturl:"",restricted:"No",lastrun:"0000-00-00"}];
		$("#datagrid").jqGrid('addRowData',0,emptyItem);
		$("#datagrid").editRow(0,true);
		$(this).attr("disabled",true); 
		$("#editrow").attr("disabled",true); 
		$("#saverow").attr("disabled",false);
		$("#cancel").attr("disabled",false);
	});
});
17/08/2010
23:05
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Well I think that this is a copy/paste typo. Try this:

$("#addrow").click( function() {
emptyItem=[{id:"",jobname:"",process:"stopped",disabled:"No",description:"",frequency:"manual",fromemail:"",fromname:"",replyemail:"",subject:"",contenturl:"",restricted:"No",lastrun:"0000-00-00"}];
$("#datagrid").jqGrid('addRowData',0,emptyItem);
$("#datagrid").jqGrid('editRow', 0,true);
$(this).attr("disabled",true);
$("#editrow").attr("disabled",true);
$("#saverow").attr("disabled",false);
$("#cancel").attr("disabled",false);
});

Kind Regsrds
Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
81 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information