Alright now I see a little better what is going. Last night I wasn't
able to check what the jqgrid_editable_plugin really was. To my
surprise it is a very nice web2py plugin. My appologise for pushing
the jqgrid_plugin from web2py/plugins. Although a nice plugin this is
a very feature rich ready plugin.
Anyways, I slightly revised the plugin so that this will work for you.
I will mail it to your private mail.
Once you have replaced the new plugin files you should be able to use
it by implementing the following code.
## controller
def index():
return
dict(jqgrid_table=plugin_editable_jqgrid(db.test,grid_name='grid_test',db_name='db',grid_load=URL(r=request,c='default',f='form'),target='my_form')))
def form():
id = request.args[0]
form=FORM(TABLE(TR("Your
name:",INPUT(_type="text",_name="name",requires=IS_NOT_EMPTY())),
TR("Your
email:",INPUT(_type="text",_name="email",requires=IS_EMAIL())),
TR("Admin",INPUT(_type="checkbox",_name="admin")),
TR("Sure?",SELECT('yes','no',_name="sure",requires=IS_IN_SET(['yes','no'])) ),
TR("Profile",TEXTAREA(_name="profile",value="write
something here")),
TR("",INPUT(_type="submit",_value="SUBMIT"))))
if form.accepts(request.vars,session):
response.flash="form accepted"
elif form.errors:
response.flash="form is invalid"
else:
response.flash="please fill the form"
return dict(form=form,vars=form.vars)
## view
{{extend 'layout.html'}}
<h1>This is the default/test.html template</h1>
{{=jqgrid_table}}
{{=LOAD('default','details',args=1,ajax=True,target='my_form')}}
// Notice the two extra options (grid_load='URL(...)',target='id') in
the controller default/index.
grid_load = url to the form controller function
target = This should match the LOAD(target='id')
Hope this works for you.. :)
On May 21, 1:43 am, Jason Lotz <[email protected]> wrote:
> Can you explain a liitle more? You are actually seeing two forms in
> the browser?
>
> If I understand you correctly upon first loading the page you get the
> grid and a form with default id. When you select a row in the grid the
> default form is not reloaded with the new id but a second form
> appears. You see a grid and two forms. Is that right?
>
> Double check your id's. It could be that adding the extra jQuery
> ("#grid_id").jqGrid({ onSelectRow: .... }) in the view is conflicting
> with a function in the plugin. I would try making a quick test using
> the web2py jqgrid_plugin (which is a very nicely integrated plugin )
> and see if you get the same issue. If not then it is a conflict with
> your plugin script.
>
> It's passing 1:45am here so I will take a look at this editable_plugin
> tomorrow morning and see if I can find something, if you haven't
> solved it by then.
>
> On May 21, 2010, at 0:50, AsmanCom <[email protected]> wrote:
>
>
>
> > You helped me a lot, man!
>
> > i´ve tried like you suggested, i only keeped the LOAD, but it´s the
> > same...
> > Page is loading the Grid, underneath the Grid rises "loading" and then
> > a new layer pops up with with the form in the default Template (Its
> > showed twice).
>
> > I´ve checked:
> >www.web2py.com/AlterEgo/default/show/252
>
> > But it doesent´t helped very much.
>
> > It seems I am stucked, right before finish... ;-(
>
> > Any help is appreciated, would so cool if I could get this done today.
>
> > Dieter Asman
>
> > On 20 Mai, 17:23, Jason Lotz <[email protected]> wrote:
> >> web2py LOAD function will create generate <div
> >> id="target">Loading...</div> and fills your component. I'm sorry I
> >> can't
> >> test it right now but it seems that by adding the <div></div> in your
> >> view and including the LOAD you are creating two form. Maybe try
> >> remove
> >> your div and only keep the LOAD.
>
> >> {{extend 'layout.html'}}
> >> <h1>This is the default/test.html template</h1>
> >> {{=jqgrid_table}}
> >> <script type="text/javascript">
> >> jQuery(document).ready(function()
> >> {jQuery("#grid_id").jqGrid({onSelectRow: function(postdata)
> >> {web2py_ajax_page('get','/myapp/default/form/'+
> >> (postdata),null,'my_form');}});
> >> </script>
> >> {{=LOAD('default','form',args=1,ajax=True,target='my_form')}}
>
> >> check out LOAD function dochttp://www.web2py.com/AlterEgo/default/
> >> show/252
>
> >> On 05/21/2010 12:09 AM, AsmanCom wrote:
>
> >>> Many thanks, it go�s in the right direction now.
>
> >>> I am using thehttp://app.ebansoftware.net/editable_jqgrid/default/
> >>> show_example
> >>> , but it is quite similar.
>
> >>> Now the is loaded is loaded with the default template and then a
> >>> second layer covers it with the form and the default Template(loaded
> >>> twice)
>
> >>> The code so far:
>
> >>> View:
>
> >>> {{extend 'layout.html'}}
> >>> <h1>This is the default/test.html template</h1>
> >>> {{=jqgrid_table}}
> >>> <script type="text/javascript">
> >>> jQuery(document).ready(function()
> >>> {jQuery("#grid_id").jqGrid({onSelectRow: function(postdata)
> >>> {web2py_ajax_page('get','/myapp/default/form/'+
> >>> (postdata),null,'my_form');}});
> >>> </script>
> >>> <div id="my_form"></div>
> >>> {{=LOAD('default','form',args=1,ajax=True,target='my_form')}}
>
> >>> Controller:
>
> >>> def jqgrid_table_test():
> >>> return
> >>> dict(jqgrid_table=plugin_editable_jqgrid
> >>> (db.jqgrid_table,grid_name='jqgrid_table',db_name='db'))
>
> >>> def form():
> >>> #id = request.args[0]
> >>> form = SQLFORM(db.jqgrid_table)
> >>> if form.accepts(request.vars, session):
> >>> response.flash = 'form accepted'
> >>> elif form.errors:
> >>> response.flash = 'form has errors'
> >>> else:
> >>> response.flash = 'please fill out the form'
> >>> return dict(form=form)
>
> >>> On 20 Mai, 16:55, Jason Lotz<[email protected]> wrote:
>
> >>>> Are you using the web2py jqgrid_plugin?
>
> >>>>http://web2py.com/plugins/default/jqgrid
>
> >>>> On 05/20/2010 11:53 PM, AsmanCom wrote:
>
> >>>>> can this be caused by the function, which set in /static/
> >>>>> plugin_editable_jqgrid/plugin_editable_jqgrid.js ?:
>
> >>>>> onSelectRow: function(id){
> >>>>> if(id&& lastSel!=''&& id!==lastSel){
> >>>>> jQuery(grid_name).restoreRow(lastSel);
> >>>>> }
> >>>>> lastSel=id;
> >>>>> jQuery(grid_name).editRow(id, true, '', '', '', '',
> >>>>> function(rowid, resultText){reload(grid_name,rowid,
> >>>>> resultText);});
> >>>>> },
> >>>>> colNames:col_names,
> >>>>> colModel:col_models,
> >>>>> pager: pager,
> >>>>> rowNum:10,
> >>>>> rowList:[10,100,1000],
> >>>>> sortorder: 'desc',
> >>>>> multiselect: true,
> >>>>> multiboxonly:true,
> >>>>> viewrecords: true,
> >>>>> editurl:edit_url,
> >>>>> caption: caption
> >>>>> });
>
> >>>>> Thank you in advance.
>
> >>>>> Dieter Asman
>
> >>>>> On 20 Mai, 15:52, Jason Lotz<[email protected]> wrote:
>
> >>>>>> Try
>
> >>>>>> {{=jqgrid_table}}
> >>>>>> <script type="text/javascript">
> >>>>>> jQuery(document).ready(function(){
> >>>>>> jQuery("#grid_id").jqGrid({
> >>>>>> onSelectRow: function(postdata) {
> >>>>>> web2py_ajax_page('get','/myapp/default/form/'+
> >>>>>> (postdata),null,'my_form');}});
> >>>>>> </script>
>
> >>>>>> On 05/20/2010 10:45 PM, AsmanCom wrote:
>
> >>>>>>> Thanks for your effort, but it gives an empty page..
> >>>>>>> I will use two or more Grids at least one of them must keep the
> >>>>>>> "editable" behaveure.
> >>>>>>> But in this case it should work like your approach,
> >>>>>>> controlling the
> >>>>>>> form.
>
> >>>>>>> May i missed something..?
> >>>>>>> Could you tell me how to set up the form?
>
> >>>>>>> should the view look something like that?:
>
> >>>>>>> {{=jqgrid_table}}
> >>>>>>> <script>
> >>>>>>> jQuery("#grid_id").jqGrid({
> >>>>>>> onSelectRow: function(postdata) {
> >>>>>>> web2py_ajax_page('get','/myapp/default/form/'+
> >>>>>>> (postdata),null,'my_form');
> >>>>>>> }
>
> >>>>>>> });
> >>>>>>> </script>
> >>>>>>> <div id='my_form'></div>
> >>>>>>> {{=form}}
>
> >>>>>>> Thank you in advance.
>
> >>>>>>> Dieter Asman
>
> >>>>>>> On 20 Mai, 14:54, Jason Lotz<[email protected]> wrote:
>
> >>>>>>>> You could try passing SCRIPT from the controller.
>
> >>>>>>>> ## View
> >>>>>>>> {{extend 'layout.html'}}
> >>>>>>>> <h1>This is the default/test.html template</h1>
> >>>>>>>> {{=plugin_editable_jqgrid(db.jqgrid_table,grid_name='jqgrid_
> >>>>>>>> table',db_name='db')}}
> >>>>>>>> {{=script}}
>
> >>>>>>>> ## Controller
> >>>>>>>> def jqgrid_table_test():
> >>>>>>>> script = """jQuery(document).ready(function(){
> >>>>>>>> jQuery("#grid_id").jqGrid({
> >>>>>>>> onSelectRow: function(postdata)
> >>>>>>>> {web2py_ajax_page('get','/myapp/default/form/'+
> >>>>>>>> (postdata),null,'my_form'); }});"""
> >>>>>>>> return SCRIPT(script)
>
> >>>>>>>> I haven't tested this so let me know if it works out for you.
>
> >>>>>>>> I am only using a single grid for my app so I actually
> >>>>>>>> included the
> >>>>>>>> onSelectRow event to /models/jqgrid_plugin. The function
> >>>>>>>> plugin_jqgrid() is where the default jqgrid script is
> >>>>>>>> retrieved when
> >>>>>>>> the {{=plugin_jqgrid(db.table,columns=[...])}} is called. If
> >>>>>>>> you do it
> >>>>>>>> this way you will want to add it to the .jqGrid({ })
> >>>>>>>> parameters not in
> >>>>>>>> the 'navGrid', 'toolbar' or other extended option parameters.
>
> >>>>>>>> Jay
>
> >>>>>>>> On May 20, 8:47 pm, AsmanCom<[email protected]> wrote:
>
> >>>>>>>>> Could you help me setting this up too?
>
> >>>>>>>>> This is the view:
>
> >>>>>>>>> {{extend 'layout.html'}}
> >>>>>>>>> <h1>This is the default/test.html template</h1>
> >>>>>>>>> {{=jqgrid_table}}
> >>>>>>>>> jQuery("#grid_id").jqGrid({
> >>>>>>>>> onSelectRow: function(postdata) {
> >>>>>>>>> web2py_ajax_page('get','/myapp/default/form/'+
> >>>>>>>>> (postdata),null,'my_form');
> >>>>>>>>> }
>
> >>>>>>>>> });
>
> >>>>>>>>> This is the Controller:
>
> >>>>>>>>> def jqgrid_table_test():
> >>>>>>>>> return
> >>>>>>>>> dict(jqgrid_table=plugin_editable_jqgrid
> >>>>>>>>> (db.jqgrid_table,grid_name='jqgrid_ table',db_name='db'))
>
> >>>>>>>>> def form():
> >>>>>>>>> id = request.args[0]
> >>>>>>>>> form=FORM(TABLE(TR("Your
> >>>>>>>>> name:",INPUT(_type="text",_name="name",requires=IS_NOT_EMPTY
> >>>>>>>>> ())),
> >>>>>>>>> TR("Your
> >>>>>>>>> email:",INPUT(_type="text",_name="email",requires=IS_EMAIL
> >>>>>>>>> ())),
> >>>>>>>>> TR("Admin",INPUT
> >>>>>>>>> (_type="checkbox",_name="admin")),
>
> >>>>>>>>> TR("Sure?",SELECT('yes','no',_name="sure",requires=IS_IN_SET
> >>>>>>>>> (['yes','no'])) ),
> >>>>>>>>> TR("Profile",TEXTAREA
> >>>>>>>>> (_name="profile",value="write
> >>>>>>>>> something here")),
> >>>>>>>>> TR("",INPUT
> >>>>>>>>> (_type="submit",_value="SUBMIT"))))
> >>>>>>>>> if form.accepts(request.vars,session):
> >>>>>>>>> response.flash="form accepted"
> >>>>>>>>> elif form.errors:
> >>>>>>>>> response.flash="form is invalid"
> >>>>>>>>> else:
> >>>>>>>>> response.flash="please fill the form"
> >>>>>>>>> return dict(form=form,vars=form.vars)
>
> >>>>>>>>> ################################################
>
> >>>>>>>>> The JQGrid works, but underneath the Grid i only see the
> >>>>>>>>> following
> >>>>>>>>> text:
> >>>>>>>>> jQuery("#grid_id").jqGrid({ onSelectRow: function(postdata)
> >>>>>>>>> { web2py_ajax_page('get','/core/default/form/'+
> >>>>>>>>> (postdata),null,'my_form'); } });
>
> >>>>>>>>> It would be very nice if you could help me gettin this to
> >>>>>>>>> work.
> >>>>>>>>> Thank you in advance.
>
> >>>>>>>>> Dieter Asman
>
> ...
>
> read more »