[web2py] Re: removing .load extension from grid pagination and export csv links

2013-08-03 Thread Matt Grham
Thanks, links are always trapped now. Works great. 

Matt

On Saturday, August 3, 2013 5:14:49 AM UTC-7, Niphlod wrote:
>
> you need to use web2y.js's component() function to have the same behaviour 
> of the standard LOAD().
> You're using jQuery.load() that is the jquery default way to replace an 
> html element with something retrieved by the server, but it doesn't add all 
> the bits that are needed to trap the links, for example.
>
> However, what you're trying to do (reload a component every n seconds) is 
> right built into the LOAD() helper.
> Use it this way:
>
> LOAD('default', 'thisgrid.load', ajax=True, target='mydiv', timeout=3, 
> times='Infinity')
>
> if you still need to use the function to load something "on demand", the 
> js signature of the component() function is:
>
> $.web2py.component(remote, target, timeout, times [, element])
>
> in your case, $.web2py.component('/appname/default/thisgrid.load', 
> 'mydiv', 3, 'Infinity')
>
> With the new  web2py.js, however, you can just have the same functionality 
> just creating a DIV with the proper  data- attributes (this is what LOAD() 
> does)...
>
> DIV(_id="mydiv", data=dict(w2p_remote=URL('default', 'thisgrid.load'), 
> w2p_times='Infinity', w2p_timeout=3)) 
>
> On Saturday, August 3, 2013 4:10:49 AM UTC+2, Matt Grham wrote:
>>
>> Thanks a lot Niphlod. Actually that was the case. I started to use 
>> web2py 2.4.6 but my app was built using web2py 1.99.7. I updated web2py.js, 
>> web2py_ajax.html and layout.html. It works now. But if I want to refresh 
>> the component in every 30 seconds, I am having a problem. Sometimes 
>> pagination links or sorting links are not trapped. How can I refresh the 
>> component properly?
>>
>> The following helps to refresh, but links are not trapped in some cases. 
>>
>> in container.html:
>>
>> {{extend 'layout.html'}}
>>
>> {{=frag}}
>>
>> 
>> jQuery(document).ready(function(){
>> var auto_refresh = setInterval(
>> function()
>> {
>> $('#mydiv').load('{{=URL(r=request,c='default',f='thisgrid.load' )}}'); 
>> }, 3);
>> });
>> 
>>
>> in controller (target is added):
>>
>> def container():
>> frag = LOAD('default', 'thisgrid.load', ajax=True, target='mydiv')
>> return dict(frag=frag)
>>
>>
>> On Friday, August 2, 2013 1:24:22 PM UTC-7, Niphlod wrote:
>>>
>>> did you start with an old (pre 2.6.0) app and updated web2py ? if yes, 
>>> you need to overwrite your app's web2py.js with welcome/static/web2py.js
>>> I think that the most straightforward example is (assuming working on 
>>> localhost, hence having generic views enabled): take your welcome, put this 
>>> in default.py
>>>
>>> def thisgrid():
>>> grid = SQLFORM.grid(db.your_table, paginate=5) #paginate defaults 
>>> altered just to avoid having a huge test table filled for this test
>>> return dict(grid=grid)
>>>
>>> def container():
>>> frag = LOAD('default', 'thisgrid.load', ajax=True)
>>> return dict(frag=frag)
>>>
>>>
>>> then access the container page.
>>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: removing .load extension from grid pagination and export csv links

2013-08-03 Thread Niphlod
you need to use web2y.js's component() function to have the same behaviour 
of the standard LOAD().
You're using jQuery.load() that is the jquery default way to replace an 
html element with something retrieved by the server, but it doesn't add all 
the bits that are needed to trap the links, for example.

However, what you're trying to do (reload a component every n seconds) is 
right built into the LOAD() helper.
Use it this way:

LOAD('default', 'thisgrid.load', ajax=True, target='mydiv', timeout=3, 
times='Infinity')

if you still need to use the function to load something "on demand", the js 
signature of the component() function is:

$.web2py.component(remote, target, timeout, times [, element])

in your case, $.web2py.component('/appname/default/thisgrid.load', 'mydiv', 
3, 'Infinity')

With the new  web2py.js, however, you can just have the same functionality 
just creating a DIV with the proper  data- attributes (this is what LOAD() 
does)...

DIV(_id="mydiv", data=dict(w2p_remote=URL('default', 'thisgrid.load'), 
w2p_times='Infinity', w2p_timeout=3)) 

On Saturday, August 3, 2013 4:10:49 AM UTC+2, Matt Grham wrote:
>
> Thanks a lot Niphlod. Actually that was the case. I started to use web2py 
> 2.4.6 but my app was built using web2py 1.99.7. I updated web2py.js, 
> web2py_ajax.html and layout.html. It works now. But if I want to refresh 
> the component in every 30 seconds, I am having a problem. Sometimes 
> pagination links or sorting links are not trapped. How can I refresh the 
> component properly?
>
> The following helps to refresh, but links are not trapped in some cases. 
>
> in container.html:
>
> {{extend 'layout.html'}}
>
> {{=frag}}
>
> 
> jQuery(document).ready(function(){
> var auto_refresh = setInterval(
> function()
> {
> $('#mydiv').load('{{=URL(r=request,c='default',f='thisgrid.load' )}}'); 
> }, 3);
> });
> 
>
> in controller (target is added):
>
> def container():
> frag = LOAD('default', 'thisgrid.load', ajax=True, target='mydiv')
> return dict(frag=frag)
>
>
> On Friday, August 2, 2013 1:24:22 PM UTC-7, Niphlod wrote:
>>
>> did you start with an old (pre 2.6.0) app and updated web2py ? if yes, 
>> you need to overwrite your app's web2py.js with welcome/static/web2py.js
>> I think that the most straightforward example is (assuming working on 
>> localhost, hence having generic views enabled): take your welcome, put this 
>> in default.py
>>
>> def thisgrid():
>> grid = SQLFORM.grid(db.your_table, paginate=5) #paginate defaults 
>> altered just to avoid having a huge test table filled for this test
>> return dict(grid=grid)
>>
>> def container():
>> frag = LOAD('default', 'thisgrid.load', ajax=True)
>> return dict(frag=frag)
>>
>>
>> then access the container page.
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: removing .load extension from grid pagination and export csv links

2013-08-02 Thread Matt Grham
Thanks a lot Niphlod. Actually that was the case. I started to use web2py 
2.4.6 but my app was built using web2py 1.99.7. I updated web2py.js, 
web2py_ajax.html and layout.html. It works now. But if I want to refresh 
the component in every 30 seconds, I am having a problem. Sometimes 
pagination links or sorting links are not trapped. How can I refresh the 
component properly?

The following helps to refresh, but links are not trapped in some cases. 

in container.html:

{{extend 'layout.html'}}

{{=frag}}


jQuery(document).ready(function(){
var auto_refresh = setInterval(
function()
{
$('#mydiv').load('{{=URL(r=request,c='default',f='thisgrid.load' )}}'); 
}, 3);
});


in controller (target is added):

def container():
frag = LOAD('default', 'thisgrid.load', ajax=True, target='mydiv')
return dict(frag=frag)


On Friday, August 2, 2013 1:24:22 PM UTC-7, Niphlod wrote:
>
> did you start with an old (pre 2.6.0) app and updated web2py ? if yes, you 
> need to overwrite your app's web2py.js with welcome/static/web2py.js
> I think that the most straightforward example is (assuming working on 
> localhost, hence having generic views enabled): take your welcome, put this 
> in default.py
>
> def thisgrid():
> grid = SQLFORM.grid(db.your_table, paginate=5) #paginate defaults 
> altered just to avoid having a huge test table filled for this test
> return dict(grid=grid)
>
> def container():
> frag = LOAD('default', 'thisgrid.load', ajax=True)
> return dict(frag=frag)
>
>
> then access the container page.
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: removing .load extension from grid pagination and export csv links

2013-08-02 Thread Niphlod
did you start with an old (pre 2.6.0) app and updated web2py ? if yes, you 
need to overwrite your app's web2py.js with welcome/static/web2py.js
I think that the most straightforward example is (assuming working on 
localhost, hence having generic views enabled): take your welcome, put this 
in default.py

def thisgrid():
grid = SQLFORM.grid(db.your_table, paginate=5) #paginate defaults 
altered just to avoid having a huge test table filled for this test
return dict(grid=grid)

def container():
frag = LOAD('default', 'thisgrid.load', ajax=True)
return dict(frag=frag)


then access the container page.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: removing .load extension from grid pagination and export csv links

2013-08-02 Thread Matt Grham
Hi Niphlod,

Actually I did not change web2py.js or layout.html. Can you provide a very 
small example of a LOADed grid? My current structure might be wrong.

Thanks,

Matt

On Friday, August 2, 2013 1:46:16 AM UTC-7, Niphlod wrote:
>
> something is wrong with your layout (and possibly with web2py.js). Any 
> LOADed grid has links that are trapped by default, and all links lead to 
> change only the fragment where the grid has been loadeddid you fiddle 
> with web2py.js or layout.html ?
>
> On Friday, August 2, 2013 10:43:47 AM UTC+2, Matt Grham wrote:
>>
>> with .load, page 2 of table opens without any layout. It does not work 
>> like a component in that regard. I need to refresh the table every 30 
>> seconds. That is why, I use LOAD and reload the component in a script 
>> statement in every 30 seconds. 
>>
>> Matt
>>
>> On Friday, August 2, 2013 12:43:40 AM UTC-7, Niphlod wrote:
>>>
>>> is it an aesthetic request or something doesn't work ? if you loaded the 
>>> grid with a .load extension, pagination links needs to have .load as well 
>>> else when you change the page it will load in the fragment the whole 
>>> layout.html again, and that's probably something you don't want
>>>
>>> On Friday, August 2, 2013 7:06:22 AM UTC+2, Matt Grham wrote:

 Hi All,

 I have a grid in a LOAD component. How can I remove the .load 
 extensions from the grid links (next page and export csv links)?

 Thanks,

 Matt

>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: removing .load extension from grid pagination and export csv links

2013-08-02 Thread Niphlod
something is wrong with your layout (and possibly with web2py.js). Any 
LOADed grid has links that are trapped by default, and all links lead to 
change only the fragment where the grid has been loadeddid you fiddle 
with web2py.js or layout.html ?

On Friday, August 2, 2013 10:43:47 AM UTC+2, Matt Grham wrote:
>
> with .load, page 2 of table opens without any layout. It does not work 
> like a component in that regard. I need to refresh the table every 30 
> seconds. That is why, I use LOAD and reload the component in a script 
> statement in every 30 seconds. 
>
> Matt
>
> On Friday, August 2, 2013 12:43:40 AM UTC-7, Niphlod wrote:
>>
>> is it an aesthetic request or something doesn't work ? if you loaded the 
>> grid with a .load extension, pagination links needs to have .load as well 
>> else when you change the page it will load in the fragment the whole 
>> layout.html again, and that's probably something you don't want
>>
>> On Friday, August 2, 2013 7:06:22 AM UTC+2, Matt Grham wrote:
>>>
>>> Hi All,
>>>
>>> I have a grid in a LOAD component. How can I remove the .load extensions 
>>> from the grid links (next page and export csv links)?
>>>
>>> Thanks,
>>>
>>> Matt
>>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: removing .load extension from grid pagination and export csv links

2013-08-02 Thread Matt Grham
with .load, page 2 of table opens without any layout. It does not work like 
a component in that regard. I need to refresh the table every 30 seconds. 
That is why, I use LOAD and reload the component in a script statement in 
every 30 seconds. 

Matt

On Friday, August 2, 2013 12:43:40 AM UTC-7, Niphlod wrote:
>
> is it an aesthetic request or something doesn't work ? if you loaded the 
> grid with a .load extension, pagination links needs to have .load as well 
> else when you change the page it will load in the fragment the whole 
> layout.html again, and that's probably something you don't want
>
> On Friday, August 2, 2013 7:06:22 AM UTC+2, Matt Grham wrote:
>>
>> Hi All,
>>
>> I have a grid in a LOAD component. How can I remove the .load extensions 
>> from the grid links (next page and export csv links)?
>>
>> Thanks,
>>
>> Matt
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: removing .load extension from grid pagination and export csv links

2013-08-02 Thread Niphlod
is it an aesthetic request or something doesn't work ? if you loaded the 
grid with a .load extension, pagination links needs to have .load as well 
else when you change the page it will load in the fragment the whole 
layout.html again, and that's probably something you don't want

On Friday, August 2, 2013 7:06:22 AM UTC+2, Matt Grham wrote:
>
> Hi All,
>
> I have a grid in a LOAD component. How can I remove the .load extensions 
> from the grid links (next page and export csv links)?
>
> Thanks,
>
> Matt
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.