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
In line editing issue - data problem?
08/09/2008
16:46
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

I have a grid that has the following problem:

When I use a local data source and load the grid I can edit the columns/rows that I have indicated on my ColModel.  If I use json data, the grid displays just fine but I cannot edit the rows/columns.

What I have narrowed this down to is that in my grid I pass the following in addition to the rows of data:

{total: "1",page: "1",records:" 3",rows : [
 { absDate:"09/24/2008", begTime:"700", endTime:"1415"},
 { absDate:"09/25/2008", begTime:"700", endTime:"1415"},
 { absDate:"09/26/2008", begTime:"700", endTime:"1415"}
 ]
}

Now, this is returned from a servlet so this is a string literal. The grid will render but I can't edit the returned records.  Is there a reason for that or is the json string incorrectly formatted?

Is there an example that uses local data to do editing in a grid that uses the format above?

Since my servlet is always returning a string literal as the json return value, I just wonder if there isn't something in parsing the data that is causing the problem.  For example in rowedex5.html you have a var defined as an array called mydata3.  I used that same format to do this:

var mydata3= [
 { "absDate":"09/24/2008", "begTime":700, "endTime":1415},
 { "absDate":"09/25/2008", "begTime":700, "endTime":1415},
 { "absDate":"09/26/2008", "begTime":700, "endTime":1415}
 ];

And this works.  However, if I have a json call that returns a literal string like this:

 { "absDate":"09/24/2008", "begTime":700, "endTime":1415},
 { "absDate":"09/25/2008", "begTime":700, "endTime":1415},
 { "absDate":"09/26/2008", "begTime":700, "endTime":1415}

It will not work the grid will not render.  Even a literal string returned by json that looks like this:

 [ { "absDate":"09/24/2008", "begTime":700, "endTime":1415},
 { "absDate":"09/25/2008", "begTime":700, "endTime":1415},
 { "absDate":"09/26/2008", "begTime":700, "endTime":1415} ]

Won't work.  However if I return a string like this:

{total: "1",page: "1",records:" 3",rows : [
 { absDate:"09/24/2008", begTime:"700", endTime:"1415"},
 { absDate:"09/25/2008", begTime:"700", endTime:"1415"},
 { absDate:"09/26/2008", begTime:"700", endTime:"1415"}
 ]
}

The grid will render but I cannot edit the row/column. In each case the colModel does not change, except for the url for the json call and the datatype of json rather than local.

I am not familiar enough with PHP to compare your PHP example to a java servlet but it appears my formatting of the return string for json is the problem.  Any suggestions?

09/09/2008
01:14
Avatar
drlinux
Member
Members
Forum Posts: 25
Member Since:
26/08/2008
sp_UserOfflineSmall Offline

Have u edit file in your directory?

09/09/2008
16:11
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

Not sure what you mean by "in the directory".  The data is returned by a json call and doesn't reside anywhere but in memory as far as I know.

When I use "local" data, the data is in the javascript as a var.

I think my json data is improperly formatted but when I look at the actual data returned in debug, it is identical to the data that the javascript var would have.

09/09/2008
16:24
Avatar
YamilBracho
Member
Members
Forum Posts: 124
Member Since:
08/09/2008
sp_UserOfflineSmall Offline

Hi.

Not sure what is going on here but I think you have to add a navigation bar and specify you wanto to edit

.navGrid("#prowed1",{edit:false,add:false,del:false});

See the http://trirand.com/jqgrid/jqgrid.html

HTH

10/09/2008
10:16
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello

What do you use inline edit or form edit?

Regards

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.

14/09/2008
23:02
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

Tony (sorry for the delay)

I want to do an inline edit.  I used the example rowedex5.html to start with.  I modified the colModel and the data var to use data that was like my application and then I was able to display and edit the grid using "local" data.  No problem.

Then I replaced the "local" data with a json call to my servlet and although the data comes back from the servlet OK, I can see it in the grid, I cannot edit it.  I am not sue what would be in the json data that would prevent editing but that seems to be the case.

Thanks

16/09/2008
02:42
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

I think,  nothing special.. Just check your code again.

Best Regards

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.

16/09/2008
09:30
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

I actually have checked the code several times.  The ONLY thing that is different is the json string in my code that returns a literal string like this:

{total: “1″,page: “1″,records:” 3″,rows : [
 { absDate:"09/24/2008", begTime:"700", endTime:"1415"},
 { absDate:"09/25/2008", begTime:"700", endTime:"1415"},
 { absDate:"09/26/2008", begTime:"700", endTime:"1415"}
 ]
}

This is a string value. The grid will render but isn't editable.  If the json call returns this literal string:

 { absDate:"09/24/2008", begTime:"700", endTime:"1415"},
 { absDate:"09/25/2008", begTime:"700", endTime:"1415"},
 { absDate:"09/26/2008", begTime:"700", endTime:"1415"}

I get no grid rendered at all.

Can you think of a reason as to why that would be?  Does your PHP code return literal strings to your grids for parsing?

16/09/2008
11:20
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

How you edit the row. If possible send me jqGrid options and code where

you edit the row. I think that the problem is that you do not have set

the row id - i.e the uniquie row  where you cando editing.

Regards

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.

16/09/2008
17:48
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

Tony,

I spent 3 or 4 hours on this while I was flying out to New York this morning and you came up with the same conclusion as I did.  I think the ID is problem and jqgrid cannot handle inline editing when you have taken the jsonreader option id:"0".  The colModel looks like this:

$("#workTimes").jqGrid({
   url: url,
   datatype: "json",
   colNames:['Absence Date', 'Begin Time', 'End Time'],
  colModel:[
   {name:'absDate',index:'absDate', width:120, sorttype:"date"},
   {name:'beginTime',index:'beginTime', width:100, editable: true,editoptions:{size:10}},
   {name:'endTime',index:'endTime', width:100, editable: true,editoptions:{size:10}}
   ], 
  rowNum:10,
  rowList:[10,20,30],
  imgpath: gridimgpath,
  pager: $('#pager'),
  sortname: 'absDate',
     onSelectRow: function(id){
        if(id && id!==lastsel3){
            $('#workTimes').restoreRow(lastsel3);
            $('#workTimes').editRow(id,true);
            lastsel3=id;
        }
    },
  sortorder: "desc",
  jsonReader: {repeatitems: false, cell: "", id: "0"},
  caption: "Employee Work Times"
  });

You can look at the data returned by json in my posts above. The absDate *was* set as the id originally.  The way I got this to work as to eliminate the id:"0" from the jsonreader in the colModel and then add an id number to the json data.  However, this is only a work around, what I need is a fix that will allow me to set the id and allow the inline editing.  Again, in the example above, if I set id:"absDate" in the colModel, the grid won't support inline editing.

What does the id:"0" signify? Page 32 of the manual says "And, it is possible to set the id as number." Is that all id:"0" does? Set the id to allow a numeric value?  I don't see an example that shows how you can set the id to another value using json data.  Is there an example of this?

So, I know the id is the problem.  How can I set the value so that I can use the absDate data as indicated in my earlier posts.

Thanks for the help.

17/09/2008
05:07
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Yes there is a bug when id:"0" - have corrected this.

For now you can use id:"Absence Date" , or simply set in the colModel

colModel:[
{name:'absDate',

index:'absDate',

width:120,

sorttype:"date",

key: true

},

....

Best Regards

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.

19/09/2008
14:19
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

Thanks again Tony.  I thought it might be a bug but, I am such a newbie that I figured it was something I was doing.

I tried both of your workarounds and neither worked.  When I used the key:true in the colModel, the grid rendered but couldn't be edited. When I used id:"Absence Date" the grid wouldn't render and I got a javascript error:

ts.p.colModel[idn] is undefined
http://localhost:8090/asaap3/scripts/js/grid.base.js
Line 626

So I will go back to using an id column in my json, but that isn't going to work in every situation.

I'd be happy to test your bug fix when you think it is ready to try. Smile

Pete

20/09/2008
05:21
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Actually this should be:

id: "absDate" and not id:"Absence Date",

since you do not have defined Absence Date as name, but as label.

This should work.

Regards

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.

22/09/2008
18:12
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

Even with the change to id: “absDate” it still doesn't work.  In debug I see the data coming back in the "rowid" parameter.  So using the data earlier in this post as an example, if I clicked on the first row, debug would show "09/24/08" as the rowid parameter in the editRow function. But the function doesn't continue processing, it simply returns.

Perhaps the "/" in the date is creating an issue?

If I use a field called "id" in the json data and add a number to each row, I do get the correct data in the grid and it is editable.

Ideas?

23/09/2008
04:49
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Yes you are right - please see

http://htmlhelp.com/reference/.....attrs.html

Regards

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.

23/09/2008
12:41
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

Thanks again.

I guess I'll have to figure out to how to work around the problem.  I might be able to reformat the date but it is coming from flexjson and I don't know how much control I am going to have.

I appreciate the help.

Pete

23/09/2008
15:43
Avatar
Pete
Member
Members
Forum Posts: 100
Member Since:
01/09/2008
sp_UserOfflineSmall Offline

Tony,

Reformatting the date as 09-23-2008 took care of the problem.  Might be something to add to the documentation as a point of clarificaton.

Thanks again.

Pete

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
34 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