Never mind. Saw Massimo's Post.

https://groups.google.com/forum/#!searchin/web2py/selection$20checkbox/web2py/MbTywc4upms/JUNvqOljt7AJ

This site is becoming a book itself! lol. 

On Tuesday, February 23, 2016 at 11:27:31 AM UTC-5, Ron Chatterjee wrote:
>
> On the same table, if I want to create a selectable. Pretty much like this 
> google group. How do I put a check box next to my table rows in that array 
> and then on_click go to a function to star each post?
>
> hobby_str = ['baseball', 'basketball', 'tennis', 'football', 'soccar']
> db.define_table("Post",
>                 Field("Title", "string", label='Give it a Title*', 
> requires=IS_NOT_EMPTY(),default=None),
>                 Field("body", "text", label='Say something', 
> requires=IS_NOT_EMPTY(),default=None),
>                 Field('game', 
> type='list:string',label='hobbies',requires=IS_IN_SET ((hobby_str), 
> multiple=True),widget=lambda field, value: 
> SQLFORM.widgets.multiple.widget(field, value, size=3, style='divs', 
> label=True)),
>                 Field('star',"boolean"),
>                 Field('schedule',comment = 'Check all that applies', 
> requires=IS_EMPTY_OR(IS_IN_SET(('day','Night', 'weekend only','weekdays', 
> 'excluding holidays'),multiple=True)),widget=lambda field,  value: 
> SQLFORM.widgets.checkboxes.widget(field, value, style='divs', label=True, 
> _class='horizontal')),)
>
> This don't seem to work.
>
>
> On Sunday, February 21, 2016 at 4:28:55 PM UTC-5, Ron Chatterjee wrote:
>>
>> I found a workaround. But minor problem still trying to solve. 
>>
>> Let's say I have:
>>
>> a = projects[7].Terms
>> a
>> 'Part Time'
>>
>> b = projects[8].Terms
>> b
>> '|Part Time|Hourly|Remote|'
>>
>> I want to get all the ids from projects that matches "a " which is 'Part 
>> Time' or get all the ids that has any of the string [Part Time, Hourly or 
>> Remote] as I have for "b"
>>
>> db(db.Project.terms.contains(a)).select()
>>
>> I get everything matches Partime. And I go display that. Perfect.
>>
>> But when I do db(db.Project.terms.contains(b)).select()
>>
>> I only get one id. It doesn't sought for both a and b. Means the string 
>> that belongs to both projects. In other words if I have 3 more projects one 
>> with Remote, one with hourly and one with Parttime. by doing 
>> db(db.Project.terms.contains(b)).select(). I was hoping all of them show 
>> up. It works the other way around. 
>>
>>
>>
>>
>> On Friday, February 19, 2016 at 2:47:36 PM UTC-5, Dave S wrote:
>>>
>>>
>>>
>>> On Friday, February 19, 2016 at 10:06:51 AM UTC-8, Ron Chatterjee wrote:
>>>>
>>>> Was looking in the book for an example and can't seem to find it.
>>>>
>>>> Want to do something very similar to this with tags (postgresql 
>>>> <http://careers.stackoverflow.com/jobs/tag/postgresql> java 
>>>> <http://careers.stackoverflow.com/jobs/tag/java> angularjs 
>>>> <http://careers.stackoverflow.com/jobs/tag/angularjs> sass 
>>>> <http://careers.stackoverflow.com/jobs/tag/sass> css 
>>>> <http://careers.stackoverflow.com/jobs/tag/css>)
>>>>
>>>>
>>>> http://careers.stackoverflow.com/jobs/107630/software-engineer-nest-financial
>>>>
>>>> I want to create tags and have links to them using the urls.
>>>>
>>>> my model:
>>>> hobby_str = ['baseball', 'basketball', 'tennis', 'football', 'soccar']
>>>> db.define_table("Post",
>>>>                 Field("Title", "string", label='Give it a Title*', 
>>>> requires=IS_NOT_EMPTY(),default=None),
>>>>                 Field("body", "text", label='Say something', 
>>>> requires=IS_NOT_EMPTY(),default=None),
>>>>                 Field('game', 
>>>> type='list:string',label='hobbies',requires=IS_IN_SET ((hobby_str), 
>>>> multiple=True),widget=lambda field, value: 
>>>> SQLFORM.widgets.multiple.widget(field, value, size=3, style='divs', 
>>>> label=True)),
>>>>                 Field('schedule',comment = 'Check all that applies', 
>>>> requires=IS_EMPTY_OR(IS_IN_SET(('day','Night', 'weekend only','weekdays', 
>>>> 'excluding holidays'),multiple=True)),widget=lambda field,  value: 
>>>> SQLFORM.widgets.checkboxes.widget(field, value, style='divs', label=True, 
>>>> _class='horizontal')),)
>>>>
>>>> control:
>>>> def show_links():
>>>>     posts = []
>>>>     posts = db().select(db.Post.ALL)
>>>>     return locals()
>>>>
>>>> view:
>>>> {{import numpy}}
>>>>
>>>> <table>
>>>>     <td><b>Title</b></td>
>>>> <td><b>Game</b></td>
>>>> <td><b>Schedule</b></td>
>>>>    
>>>>     {{for i in range(0,len(posts)):}}
>>>> <tr>
>>>>     <td>{{=posts[i].Title}}</td>
>>>>     <td>{{=posts[i].game}}</td>
>>>>     <td>{{=posts[i].schedule}}</td>
>>>> </tr>
>>>> {{pass}}
>>>> </table>
>>>>
>>>> All the fields that show up as football, baseball, excluding holidays. 
>>>> I want them to behave as tags and by clicking them user can see the post 
>>>> related to those events only. For example. If someone click on basketball, 
>>>> all the posts related to basketball (s) will be grouped and shown 
>>>> together. 
>>>> Any examples?
>>>>
>>>>
>>>
>>> No, but isn't the key element doing the db query?  It would be something 
>>> similar to this from the Simple Wiki example:
>>>
>>>
>>> def search():
>>>  """an ajax wiki search page"""
>>>  return dict(form=FORM(INPUT(_id='keyword',_name='keyword',
>>>  _onkeyup="ajax('callback', ['keyword'], 'target');")),
>>>  target_div=DIV(_id='target'))
>>>
>>>
>>> I think that when Massimo was last presenting in SoCal, he did a simple 
>>> tagging demonstration, so you might look to see if he has that in one of 
>>> the video examples, but now that you've done the star ratings, I think 
>>> you've got the tools you need.
>>>
>>> /dps
>>>
>>>
>>>
>>>
>>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to