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
custom formating of data provided by dataUrl
31/10/2009
17:26
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hello Tonny!

There is a nice feature in jqGrid, which I cannot currently use: dataUrl.

My problem is that because of architecture design and some implementation problem I cannot easy give back HTML fragments required for dataUrl. But I can very easy provide the same information as a JSON data.

In grid.common.js in the complete function after jQuery.ajax request (line 318) the response data of data.responseText are waiting in the form

<select>

<option value='1'>One</option>

<option value='2'>Two</option>

</select>

and will be directly used as

 var a = jQuery(data.responseText).html();

It would be nice to include an additional function like customDecode(responseText), which could be defined in the editoptions together with dataUrl. CustomDecode function could convert the response text in the <select>…</select> form or in any another form, which better for using in jqGrid.

It will be very small change in the code of jqGrid, but it will be makes more flexibility in usage of jqGrid. Such changes seems to me very close another features implemented in jqGrid 3.6.

 

Thanks

Oleg

01/11/2009
01:26
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello Oleg,

I think that this is not needed. If you see a little below into the code you will see the following

jQuery.ajax(jQuery.extend({
      url: options.dataUrl,

      complete : function(res, status) {

     ..............

     }

      .....

},ajaxso || {}));

As can be seen, the complete function can be overwritten with your own using the ajaxso options. I will try to document this today.

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.

01/11/2009
14:29
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hello Tonny,

you are right of cause, that one could overwrite complete function in all $.ajax requests with respect of $.jgrid.ajaxOptions, ajaxEditOptions or ajaxso parameters. But on the other side if somebody does so, he’ll receive problem of using internal jqGrid structures. In complete function inside of createEl in grid.common.js for example one needs use options and other variable in the scope.

The main idea of my suggestion is very easy. With respect of custom serialization/deserialization functions one could change paradigm of jqGrid usage on the side of backend services. Currently one has to provide on the backend server services providing data for jqGrid in a special format prepared for jqGrid. If you allow to use custom serialization and destabilization functions, if would be possible use many existing backend services and convert data for jqGrid before and after $.ajax requests. The conversion can de done on the client side, without any additional requirement to the backend! It could be important for lot of scenarios of jqGrid usage.

Functions serializeGridData, serializeRowData, serializeEditData from v.3.6 provide serialization, but I found no deserialization functions. There are exists also errorfunc, errorTextFormat, which are very useful for decode error messages provided by server.

Why not provide functions like deserializeGridData etc., which could convert data send from server (responseText) to format needed for jqGrid? For example, for conversion from JSON format to HTML fragment (<select>…</select>) like in the case of dataUrl?

Best regards

Oleg

02/11/2009
04:34
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello Oleg,

I see this. Ok. Will do it for the select - a callback wich can be used whitin the complete to accept diffrent formats from server  and construc the select. Little difficult to do it for the searchGrid selects, but..

Best

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.

02/11/2009
04:41
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Thank you very much, Tonny!

Oleg

05/11/2009
09:40
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Oleg,

Could you please test the 3.6RC - there is a event buildSelect, which can be used for this purpose. Also available in editoptions and searchoptions. I have updated the documentation for this. Please let me know if it work OK for you.

Thanks

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.

05/11/2009
16:08
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hi Tony,

I tested buildSelect feature only in the case of edittype: 'select' and editoptions: { dataUrl:'...', buildSelect: mybuildSelectFunction}. There is a small problem which can be easy fixed: mybuildSelectFunction will be called two times: first expected in line 326 of grid.common.js (var b = options.buildSelect(data);) and another time unexpected with 0 as data in the line 340 (jQuery(elem).attr(options);).

To fix the problem one can add, for example, after the line 326 (var b = options.buildSelect(data);) the following line:

    try { delete options['buildSelect']; } catch (e) { }

Exactly like you do in the line 323:

    try {delete options['dataUrl'];delete options['value'];} catch (e){}

Another small problem, that you add {nd:new Date().getTime()} as a "data" parameter of jQuery.ajax request (see line 321). It force executing jQuery.ajax in IE, but switch off response cashing (see http://www.trirand.com/blog/?page_id=393/bugs/no-caching-of-server-data-because-of-new-nd-property-in-prmnames&value=sf%25members%251%25user1671&search=2&ret=all). To fix the problem I had to use ajaxSelectOptions, which are seen in createEl() as ajaxso. It works now very good, but I am not sure, that setting ajaxSelectOptions: { data: ""} for $.jgrid.defaults is OK for all other places of ajaxSelectOptions usage.

After all such changes everything works perfectly. One more time thanks for the nice feature buildSelect.

Generally I see buildSelect function as a custom deserialization after an ajax request. Version 3.6 has not serialisation for all $.ajax calls. Do you think to implement also custom deserialization? For example, if jqGrid will provide not only serializeGridData, serializeRowData, serializeEditData etc. functions, but also deserializeGridData etc. which convert responseText to format needed for jqGrid, then one could be able fill jqGrid with data not prepared specially for jqGrid. For example, one can call Amazon of twitter services and fill jqGrid with the response data. Is it not interesting?

Best regards

Oleg

06/11/2009
12:17
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Oleg,

Thanks . Fixed. Also removed new Date from data.

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.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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