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
Using JQGrid totally from Client Side
17/02/2010
14:05
Avatar
Cael
São Paulo - Brazil
Member
Members
Forum Posts: 6
Member Since:
11/02/2010
sp_UserOfflineSmall Offline

Hi,

Currently I am using the JQGrid in my project, and one of the requirements was use inline editing. As my datasource is an JSON, I was using datatype='clientSide' combined with cellsubmit='clientArray' so this both options allow me use the inline editing - I can update cell data with no problem

But the main problem was when I was trying to add a new line to the grid -- first I tried to use the Add navGrid button but I was getting error 'cause this button tries to post the new cell data to an URL -- which wasn't set up, since I am using only and JSON array (just for your information, I am populating this array with an ASP.NET Repeater component). So I got stucked in this error, until I read your JQGrid source code - when I realized that I could download the source edition and do my changes, so I could use the Grid totally from Client Side.

And that's what I've done. I downloaded the source of version 3.6.3 and added some lines in the file grid.formedit.js - at function postIt()

At line 793, you try to get the URL. If there's not URL set, you set false to the ret[0] (that has the return value) and show the error message. See below the code snippet:

gurl = rp_ge.url ? rp_ge.url : $($t).jqGrid('getGridParam','editurl');
if(ret[0]) {
    if(!gurl) { ret[0]=false; ret[1] += " "+$.jgrid.errors.nourl; }
}

The change I did:

If there's no URL set, I continue the same idea (identify the action - add or update, raise the events, set and remove the class ui-state-active, and so on), but I jump over the code that post the data to the URL. So, basically,  if there's no URL set up, do not post the data. As improvement to the next version, you could do this verification:

If is there any Post URL defined?

         True: do the post to that URL

         False: If is datatype set to 'clientSide'

                    True: don't do the post action

                    False: Throw the error "There is not URL defined!"  (the same you're using currently)

Let me know what do you think about.

I strongly suggest you to add this change to the new version, because may there people who wants to use your JQGrid but only with local data ie. they want to Add, Remove or update data in the grid but don't post any data while doing these actions. With this change they can keep their data array updated with the function getChangedCells() or get any new line added with the AfterComplete event (another modification I did - now I am passing the parameter postdata (used in the scope of the function postIt ) to this event, so I can access what data was added and update my local array - probably you'll want to consider this change also).

Another suggestion - this one is harder to do - is: accept an array if the datatype == 'clientSide' and keep this array updated with the actions of the users: For example, what if we could be able to:

var my_array = [
                { column1: "data1" ,  column2: "00:30", column3: "2010-02-12", column4: "something"},

                { column1: "data2" ,  column2: "00:31", column3: "2010-02-12", column4: "example"},

                { column1: "data3" ,  column2: "00:32", column3: "2010-02-12", column4: "foo"}

];

jQuery("#selector").jqGrid({
                datatype: "clientSide",

                clientArray: my_array, //new option proposed

                colNames: ['String Column', 'Time Column', 'Date Column', 'Something Else'],

                colModel: [' ........

});

And internally you handle this my_array and keep it updated no matter the action chose - add, remove or delete - so everytime the user access this array it will have the same data than JQGrid does.

Waiting for any response,

Cael

20/02/2010
09:42
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Thanks. We will think on this direction. There are soutions for your problem. In the moment I see two.

1. Define a dummy existing file in the server and put them in the place of the url. This will solve your problems.

2. You can define a custom button in the navigator for the add and the with succes you can use on button click

addRowData to add a data and immediatley after this to edit the data with editRow.

Hope this help.

(I wonder – why you put this in the bugs – it is more feature like bug.)

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.

22/02/2010
15:20
Avatar
Cael
São Paulo - Brazil
Member
Members
Forum Posts: 6
Member Since:
11/02/2010
sp_UserOfflineSmall Offline

Hi,

Thanks for your response and for your two suggestions; as I wrote I already found a solution (by changing the source code), but your suggestions might be useful to another users. I really hope you consider these changes in the next version. 🙂

And yes, I posted this topic in the wrong category; sorry for that.

Thanks again,

Cael

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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