I get what you are saying. I wrote a function (not on web2py, but it's
javascript...)
// this will capture the 'enter' key when pressed inside the text box, so
searching works better.
function IEKeyCap(e)
{
if (e.keyCode == 13) {dsCustomers.filter(myFilterFunc)};
}
function FilterData()
{
dsCustomers.filter(myFilterFunc);
}
function StartFilterTimer()
{
if (StartFilterTimer.timerID)
clearTimeout(StartFilterTimer.timerID);
StartFilterTimer.timerID = setTimeout(function() { StartFilterTimer.timerID
= null; FilterData(); }, 100);
}
and here was my html that fired it...
<input class="searchbox" onkeyup="StartFilterTimer();" type="text"
name="srch" id="srch">
This was using the Adobe Spry framework, but it's essentially the same.
When you press a key, it starts the timer (for 100ms). If the timer was
already going and you press another key, it restarts the timer.
After 100ms, it then calls the filter function. If they press enter
(keycode 13) it will also call the filter function.
I think the problem here is that the SQLFORM.smartgrid isn't AJAX, in that
when you click 'search' instead of just reloading the grid with the
filtered data, it just redirects you (to the exact same page you're on) and
shows you the filtered data.
The only way I know to do it with AJAX is to write my own smartgrid, or use
Adobe Spry Framework because it's awesome - and you can just tell web2py
that you want that dict as a json.
On Monday, March 26, 2012 1:24:42 PM UTC-7, greenpoise wrote:
>
> What I was looking for was a type-ahead function using SQLFORM.smartgrid
> instead of typing a word and pressing search.
>
>
>
>
>
>
>
>
> On Thursday, 22 March 2012 16:15:23 UTC-7, Alan Etkin wrote:
>>
>> I think you mean SQLFORM.smartgrid.
>>
>> Book's 7.8 section (the features are explained there):
>>
>> "...
>> A SQLFORM.smartgrid looks a lot like a grid, in fact it contains a
>> grid but it is
>> designed to take as input not a query but only one table and to browse
>> said
>> table and selected referencing tables.
>> ..."
>>
>> On Mar 22, 7:16 pm, greenpoise <[email protected]> wrote:
>> > Are these two equivalents?? I remember using smartables at some point.
>> What
>> > I liked about it was the search feature without having to press any
>> button
>> > to search for my text within a table. Does SQLFORM.grid provides
>> something
>> > similar??
>> >
>> > Thanks
>> >
>> > d
>
>