another way aroud :
db.task.deadline.represent = lambda value, field: SPAN('%s' % (value), 
_class = 'text-danger' if value > request.now else 'text-success')

best regards,
stifan

On Friday, April 22, 2016 at 6:54:48 AM UTC+7, Michael Beller wrote:
>
> There are a couple of ways to do this.  I've found it easier to just add 
> to my models rather than use javascript ...
>
> If you have a date field in your model ...
>
> Field('deadline', 'date', default=request.now + (week * 4), label=T(
> 'Deadline')),
>
> you can add a represent that generates a span ...
>
> db.task.deadline.represent = lambda v, row: \
>     SPAN(prettydate(v), _class='overdue' if v and v < datetime.date.today
> () else None)
>
> then in your css just add the style you want, something like this ...
>
> /* Deadline styles */
> .overdue {background-color: red; color:white; padding:5px;}
>
>
> On Thursday, April 21, 2016 at 9:08:23 AM UTC-4, Md Anam Raihan wrote:
>>
>> I am creating task management app and i want to change color of field if 
>> deadline is completed then how to do it using javascript also i am facing 
>> problem in extracting datetime from my field??
>>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to