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
User Var on Ajax Request
02/09/2009
11:36
Avatar
brett
Boise, ID
New Member
Members
Forum Posts: 2
Member Since:
02/09/2009
sp_UserOfflineSmall Offline

I see that there is a way to pass custom information to the browser, but I would like to pass custom data back to the server. Am writing a Rails Hobo plugin for jqGrid and in the final version it will be as easy as dropping a tag <jqgrid/> onto a page to get a context aware jqGrid.

The server side will have to figure out what columns are being requested, so either having colmodel sent back with the request, or a custom var that jqGrid just passively passes back to the server on an Ajax data request/add/update would work great!  Right now I am adding a code to the ajaxurl and caching the colmodel at the server when the server serves the page.  When the json request asking for grid data is received by the server it decodes the ajaxurl to get a key where it looks up the colmodel in a persistent hash.

It would be nicer to just put the colmodel data into a custom user var and have jqGrid just passively pass it back to the server on data requests/adds/updates.  I hope I am being clear here.

For example a var named userrequest:

      jQuery("#jqitbl-bookgrid").jqGrid({
url: "json-request"
,userrequest: "colModel: [ {name:'title',index:'title',editable:true},{name:'year_published',index:'year_published',editable:true},{name:'author',index:'author',editable:true},{sortable:false,name:'have_read',index:'have_read',formatter:'checkbox',editable:true,edittype:'checkbox',editoptions:{value:'1:0'}},{name:'date_read',index:'date_read',editable:true,formatter:'date',formatoptions:{srcformat:'Y-m-d',newformat:'d-M-Y'}}]"
,editurl: "json-edit-request"
,datatype: "json"
,colNames: ['Title','Year Published','Author','Have Read','Date Read']
,colModel: [ {name:'title',index:'title',editable:true},{name:'year_published',index:'year_published',editable:true},{name:'author',index:'author',editable:true},{sortable:false,name:'have_read',index:'have_read',formatter:'checkbox',editable:true,edittype:'checkbox',editoptions:{value:'1:0'}},{name:'date_read',index:'date_read',editable:true,formatter:'date',formatoptions:{srcformat:'Y-m-d',newformat:'d-M-Y'}}]
,rowNum: 5
,forcefit: true
,caption: "Books"
});

And jqGrid would do nothing with userrequest except that if it exists, pass it back to the server on a data request/update/add/delete.

Doing it this way people don't have to code their own server response to each grid, they can just drop a <jqgrid/> tag on a page and everything else is taken care of behind the scenes because the server receives metadata with the request.

You can see a screencast of version 1 of the plugin here to get the idea. http://www.screencast.com/users/blizzardville

Thanks for creating such a fantastic grid!!!

Brett

02/09/2009
11:40
Avatar
brett
Boise, ID
New Member
Members
Forum Posts: 2
Member Since:
02/09/2009
sp_UserOfflineSmall Offline

Formatting of that previous post was awful here is another try:

I see that there is a way to pass custom information to the browser, but
I would like to pass custom data back to the server. Am writing a Rails
Hobo plugin for jqGrid and in the final version it will be as easy as
dropping a tag <jqgrid/> onto a page to get a context aware jqGrid.

The server side will have to figure out what columns are being
requested, so either having colmodel sent back with the request, or a
custom var that jqGrid just passively passes back to the server on an
Ajax data request/add/update would work great!  Right now I am adding a
code to the ajaxurl and caching the colmodel at the server when the
server serves the page.  When the json request asking for grid data is
received by the server it decodes the ajaxurl to get a key where it
looks up the colmodel in a persistent hash.

It would be nicer to just put the colmodel data into a custom user var
and have jqGrid just passively pass it back to the server on data
requests/adds/updates.  I hope I am being clear here.

For example a var named userrequest:

jQuery("#jqitbl-bookgrid").jqGrid({
         url: "json-request"
        ,userrequest: "colModel: [
{name:'title',index:'title',editable:true},
{name:'year_published',index:'year_published',editable:true},
{name:'author',index:'author',editable:true},
{sortable:false,name:'have_read',index:'have_read',formatter:'checkbox',
editable:true,edittype:'checkbox',editoptions:{value:'1:0'}},
{name:'date_read',index:'date_read',editable:true,formatter:'date',forma
toptions:{srcformat:'Y-m-d',newformat:'d-M-Y'}}]"
        ,editurl: "json-edit-request"
        ,datatype: "json"
        ,colNames: ['Title','Year Published','Author','Have Read','Date
Read']
        ,colModel: [ {name:'title',index:'title',editable:true},
{name:'year_published',index:'year_published',editable:true},
{name:'author',index:'author',editable:true},
{sortable:false,name:'have_read',index:'have_read',formatter:'checkbox',
editable:true,edittype:'checkbox',editoptions:{value:'1:0'}},
{name:'date_read',index:'date_read',editable:true,formatter:'date',forma
toptions:{srcformat:'Y-m-d',newformat:'d-M-Y'}}]
        ,rowNum: 5
        ,forcefit: true
        ,caption: "Books"
       });

And jqGrid would do nothing with userrequest except that if it exists,
pass it back to the server on a data request/update/add/delete.

Doing it this way people don't have to code their own server response to
each grid, they can just drop a <jqgrid/> tag on a page and everything
else is taken care of behind the scenes because the server receives
metadata with the request.

You can see a screencast of version 1 of the plugin here to get the
idea. http://www.screencast.com/users/blizzardville

Thanks for creating such a fantastic grid!!!

Brett

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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