-
Notifications
You must be signed in to change notification settings - Fork 12
datatype autodetection #46
Comments
What happens if you change 'url' and reloadGrid ? |
What i don't understand is that you mix :
and
These must be separate things. |
@bouks: If you change |
I mix remote and local because both are valid settings for |
"I think there is confusion in datatype since the early begining. "local" is not a datatype, it's a state. I think we must redefine 'local' out of datatype." This is not semantic. From : |
Well, tracking state in a variable that the user change via config is problematic to say the least. So decoupling state tracking from config would be a good idea anyhow. What i don't understand yet is how does your current implementation react with this code: $('#list').jqGrid({
colModel: [ name: "colName"],
data: some_data
}); Does it understand that this is local data, or does it try to run an AJAX request? Also, what about this one (Oleg mentioned it in some other discussion): $('#list').jqGrid({
colModel: [ name: "colName"],
url: ""
}); in https://github.com/openpsa/grid.js/blob/master/js/grid.base.js#L2043 since you don't use strict comparison, the autodetection will not trigger, or am I reading it wrong? |
For the first example and this moment, it understand that it is local data BUT there is no autodetection in local data (mean you must use datatype) because i implemented autodetection only for remote. For the second, you're right, it would be better to change L2043 by if(ts.p.url && ts.p.datatype != 'local'){ |
But that change would break when datatype is |
Note that "function" datatype was never managed in populate function. If you have "clientSide" datatype then, logically, you don't evaluate "url" to true because you naturally don't fill url option. |
I repeat, don't make confusion between data recognition and where data is stored. |
I'm trying to look at this from an end user perspective (i.e. without any knowledge of internals).
So, as an end user, I think to myself: When I pass |
or more specifically, when I use this code: $('#list').jqGrid({
colModel: [ name: "colName"],
data: some_data
}); why does jqGrid do an AJAX request against the current URL? |
The discussion here seems be very long and can be continued... What do you thing about the usage of auto-detection only in case if In the way one will have no side effects in existing code, but one can still change the value of What I mean is the changing of the logic to the following var useAutodetection = ts.p.datatype !== "auto" && ts.p.datatype !== "";
$.ajax($.extend({
// option without datatype
success: function(data,st, xhr) {
...
if (useAutodetection) {
...
}
...
}
},
useAutodetection ? {} : {dataType: ts.p.datatype },
$.jgrid.ajaxOptions, ts.p.ajaxGridOptions)); It will use I personally know exactly that my server returns JSON. So I would just continue explicitly specify |
@flack : because of the if(ts.p.url != null) that i propose to replace by if(ts.p.url) @OlegKi : I wanted in the first to just autodetect in case of server side data. Now you want autodetect everywhere. :) For my algorithmic point of view, there is :
|
@flack I read your post after I posted my previous remark. I full agree with you. It's difficult to understand for an end user (the developer which uses jqGrid) why one should specify One will use the code like $('#list').jqGrid({
datatype: "json",
colModel: [ name: "colName"],
url: "someUrlWhichReturnAllData",
loadonce: true
}); The code will first make Ajax request to Only because of the implementation of Look at the performance of the demo which have 90000 rows of local data and use the page size 20 rows. You can try to sort the data, and use paging. You will that modern web browsers like Chrome can process the number of data really quickly. Another demo loads 90000 rows and use 1000 rows in the page. Independent from the question whether one really need to display such long page one can see that the performance of grid is very good. The user can see the results more quickly as one have typical round trip for the request to the server. What I mean is the usage of I have now one more idea. One can remove What do you think about the kind of detection? |
@bouks : to be exact var b = new Boolean(false);
if (b) // this condition evaluates to true By the way if So all depends on which condition you really want to test. I personally don't like |
I practically always use loadonce: true. I think if(url && !local){
doAjaxRequest();
if(detection by mime type){
add[JSON|XML]Data();
} else {
jgridInternalDetection();
}
} else if(data) {
getLocalData();
jgridInternalDetection();
} Then no datatype anymore. |
Another advantage of removing datatype from "public properties" is that if the source format change (from a server flow that you can possibly have no influence on it), you don't have to change your (user) code. |
In the same thought above, we can possibly imagine that the 'xmlReader", "jsonReader", "localRader" options could be (or not if default) in the data itself and not in options. |
@bouks Where does the |
The 'local' flag (i'll call it 'source') is a "private property" that jgrid has internal use. For exemple :
OR
|
Like i said, i'd like separated "where the data come from" and "what format is the data" that are from today mixed in a single property. |
I think you guys need to come to a consensus. What's going to cause the least pain for end users? |
I think the least pain for end users is to define the minimum options and let the software do the job. |
i think by the minimum option, only the options THEY NEED, NOT the options the SOFTWARE "NEEDS". |
@OlegKi Yes, that is what i had in mind. The autodetection should only run once during the inital setup of the grid. I noticed that I forgot to write this in the original ticket, but I've updated the description now. It should be possible to combine your idea with @bouks autodetection of remote data. i.e. if |
I did autodetection for "local" data. So what i see after working about populating grid is :
So i propose in first time :
In a second time :
|
Seems sensible |
"seems" is a matter of point of view, it's not a fact. :) The "first time" is really simple. The second can be managed. |
To answer this : I started a datatype detection for both remote and "local". |
I might not have time until the weekend, and I might be wrong, so if other people are OK with it, I'm happy. |
No problem Matthew. See you soon. |
Hi @bouks, I just found the "hidden demo" that you recent comitted: http://openpsa.github.io/grid.js/demos/remote.html I fixed the ids for the click handlers, so the buttons now work as expected, but unfortunately, no request against the server is issued. I've debugged this a little and think it may have to do with your autodetection logic (or some bad interaction between it and the Oleg changes we've merged). I'm not so familiar with that code, could you take a look when you have some time? |
P.S.: The problem is here I think: https://github.com/openpsa/grid.js/blob/master/js/grid.base.js#L2403
|
I've worked around the demo problem now by setting |
Based on @bouks implementation and the feedback from @OlegKi, here's a proposal for a modified autodetection algorithm (written as pseudocode for better readability):
The autodetection should only run once, when the grid is initially constructed.
From the user's point of view, the behaviour would be like this:
Using local data:
using remote data:
using nothing at all:
using remote data from the current URL:
The text was updated successfully, but these errors were encountered: