Forum

July 10th, 2011
You must be logged in to post Login Register

Search Forums:


 






jqGrid 3.6 beta
Read original blog post

UserPost

15:39
05/11/2009


markw65

Member

posts 179

jhsu said:

As for the retrieving data part, the behaviour of hitting the server several times before the mouse is released from the scroll bar seems to be consistent across all the browsers I tested, IE6, IE7, firefox, Safari and Chrome.



So the problem here is that you dont know when the user releases the mouse (or at least, I dont – perhaps there's a way!).


What happens, is that you get a series of "grid scrolled" events. To try to prevent hitting the server too many times, Ive set it up so that when a grid scrolled event occurs it kicks off a timer. If no new scroll event occurs within the next 200ms, it fetches the data, if a new one does occur, it resets the timer.


Perhaps 200ms is too short – but much longer than that and it will seem unresponsive.


Mark

16:08
05/11/2009


markw65

Member

posts 179

Tony,


Not a critical bug, but I noticed your last git update didnt include my commit: d8effc6f310560ddd1d5ba4cbf73f5b9b00a774a


It probably wont affect anyone but me, and I have the fix :-) , but just FYI


Mark

00:48
06/11/2009


tony

Sofia, Bulgaria

Moderator

posts 7375

Mark,

I have a chance to push only once and nothing more. My saga with the Git continue. I can not push anymore.

I have do a lot of other fixes, but…

Tony

For professional UI suites for PHP, ASP.NET and ASP.NET MVC visit us at our commercial products site – trirand.net – by the very same guys that created jqGrid.

08:52
06/11/2009


tony

Sofia, Bulgaria

Moderator

posts 7375

Mark,

Now all is OK with the Git (moving the repo to Ubuntu).

Have merge the your last commit.

Regards

Tony

For professional UI suites for PHP, ASP.NET and ASP.NET MVC visit us at our commercial products site – trirand.net – by the very same guys that created jqGrid.

09:22
06/11/2009


tony

Sofia, Bulgaria

Moderator

posts 7375

Hello Roman,

Thank you for this post.

Let me discuss a little bit.

1. The article that you post say that JSON is secure and eval is not safe.

It is not really true. I think that there is not complete secured thing. This is true for JSON too. I recommend you to read this http://directwebremoting.org/b…..it_is.html

in order to understand what is happen. Another good link is here

http://solutoire.com/2007/03/1…..your-json/

2. Appling JSON parse direct to jqGrid will cause the most user not use jqGrid. The reason is how the user configure your response from the server. Let make a example:

var a = '{"a":1}';

var b = "{'b':1}";

JSON.parse(a); //–> Result OK

JSON.parse(b); //–> Fail

eval('('+a+')'); //– Result OK

eval('('+b+')'); //– Result OK

I think you see the difference. When we use standart json encoder like in PHP json_encode and (there is such one in ASP) all is ok, but in case that this is not possible the most developers write thier response like in variable b. If you read the most messages in this forum connected to json response, you will see that about 50% of the responses that users post here is like the variable b.

But when goes to speed improvements I'm open and redy to apply them if they will not brake the existing code.

For my pleasure I have made some tests only in FireFox 3.5 comparing the times of parsing and I'm surprised how JSON.parse if fast.

The tests vary, but parsing 4 columns with 300 records – take 1ms with JSON.parse and 10ms with eval – wow 10 time faster.

In order that all will be happy I introduce another option in $.jgrid object called useJSON (default false) and have made the needed changes to the parse function (also published in the GitHub)

    parse : function(jsonString) {
        var js = jsonString, msg;
        if (js.substr(0,9) == "while(1);") { js = js.substr(9); }
        if (js.substr(0,2) == "/*") { js = js.substr(2,js.length-4); }
        if(!js) { js = "{}"; }
        ($.jgrid.useJSON===true && typeof (JSON) === 'object' && typeof (JSON.parse) === 'function')
            ? msg = JSON.parse(js)
            : msg = eval('(' + js + ')');
        return  msg.hasOwnProperty('d') ? msg.d : msg;
    },

..

3. About the second I think this is great and as you can see it is already in the code.

Best Regards

Tony

For professional UI suites for PHP, ASP.NET and ASP.NET MVC visit us at our commercial products site – trirand.net – by the very same guys that created jqGrid.

10:49
06/11/2009


markw65

Member

posts 179

Hi Tony,


Great that github is working for you again!


I noticed one odd change: 5a4510e47e65d21a0681a20d72111753c2ae8459


             jQuery(celm).addClass("customelement").attr({id:options.id,name:options.name});
-            jQuery.(elem).append(celm);
+            jQuery(elem).html(celm);
The first line creates an element from the celm html, adds a class and some attributes – but does nothing with it (effectively throwing it away).
Then the new line simply inserts the html into the element…
I think what you really meant is something like:

celm = jQuery(celm).addClass("customelement").attr({id:options.id,name:options.name});
jQuery(elem).empty().append(celm);
Mark

12:12
06/11/2009


tony

Sofia, Bulgaria

Moderator

posts 7375

Mark,

As usual … Thanks Fixed.

Tony


For professional UI suites for PHP, ASP.NET and ASP.NET MVC visit us at our commercial products site – trirand.net – by the very same guys that created jqGrid.


About the jQuery Grid Plugin – jqGrid forum

Most Users Ever Online:

215


Currently Online:

71 Guests

Forum Stats:

Groups: 1

Forums: 7

Topics: 10268

Posts: 30346

Membership:

There are 11031 Members

There have been 448 Guests

There is 1 Admin

There are 2 Moderators

Top Posters:

OlegK – 1210

markw65 – 179

kobruleht – 144

phicarre – 132

YamilBracho – 124

Renso – 118

Administrators: admin (60 Posts)

Moderators: tony (7375 Posts), Rumen[Trirand] (81 Posts)




Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information