Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
defined attributes in SQLAjqGridWidget
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
jeetu  
View profile  
 More options Aug 17 2012, 12:14 am
From: jeetu <alindsha...@gmail.com>
Date: Thu, 16 Aug 2012 21:14:56 -0700 (PDT)
Local: Fri, Aug 17 2012 12:14 am
Subject: defined attributes in SQLAjqGridWidget

I have a sqlalchemy table defined like follows

class Album(DeclarativeBase):

    # Name of mapped db table
    __tablename__ = 'material'
    id = Column(Integer, primary_key=True)
    name = Column(Unicode(50), nullable=False, unique=True)
    @memoized_property
    def total_sales(self):
        do some calculation here
        return result

When I use tw2.sqla.DbListPage I can see the total_sales column like this

class AlbumIndex(tw2.sqla.DbListPage):
    entity = model.Album
    newlink = twf.LinkField(link='/album/album', text='New', value=1)

    class child(twf.GridLayout):
        name = twf.LabelField()
        total_sales = twf.LabelField()

But when I use tw2.jqplugins.jqgrid.SQLAjqGridWidget, the total_sales is
not visible. Based on the naming of the classes, it seems that both are
based on sqla only. Then why this discrepancy, or I am missing out on
something. the ajqgrid looks very nice, but is it not possible to show
defined attributes like total_sales column?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ralph Bean  
View profile   Translate to Translated (View Original)
 More options Aug 17 2012, 10:22 am
From: Ralph Bean <rb...@redhat.com>
Date: Fri, 17 Aug 2012 10:22:37 -0400
Local: Fri, Aug 17 2012 10:22 am
Subject: Re: [TW] defined attributes in SQLAjqGridWidget
Hi,

  For starters, here's the code that produces the data for that
  widget:

  https://github.com/toscawidgets/tw2.jqplugins.jqgrid/blob/develop/tw2...

  I haven't played with it in a while, but I think you might be able
  to override "colModel" and get what you want.  Unfortunately, I have
  never tried this and have no examples for you.  ;)

  Alternatively, you could try a patch at including memoized
  properties to the list of attributes that get automatically included
  and displayed.  That would be excellent, but likely much more work.

-Ralph


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jeetu  
View profile  
 More options Aug 20 2012, 12:46 am
From: jeetu <alindsha...@gmail.com>
Date: Sun, 19 Aug 2012 21:46:12 -0700 (PDT)
Local: Mon, Aug 20 2012 12:46 am
Subject: Re: [TW] defined attributes in SQLAjqGridWidget

I tried using colModel values but I am not able to get the total_sales
visible.

pager_options = {
        "colModel": [{ "name": "name"}, {"name":"total_sales"}],
        "colNames":["name", "total_sales"],

}

Or do I have to literally override the colModel?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ralph Bean  
View profile   Translate to Translated (View Original)
 More options Aug 20 2012, 9:19 am
From: Ralph Bean <rb...@redhat.com>
Date: Mon, 20 Aug 2012 09:19:39 -0400
Local: Mon, Aug 20 2012 9:19 am
Subject: Re: [TW] defined attributes in SQLAjqGridWidget

On Sun, Aug 19, 2012 at 09:46:12PM -0700, jeetu wrote:
> I tried using colModel values but I am not able to get the total_sales
> visible.

> pager_options = {
>         "colModel": [{ "name": "name"}, {"name":"total_sales"}],
>         "colNames":["name", "total_sales"],
> }

> Or do I have to literally override the colModel?

Literally overriding it is what I had in mind.  If you see
:meth:`_get_metadata` here:  http://bit.ly/QSrnEg  It uses
:meth:`_make_model` across only the properties.  If you override
cls.colModel with your own custom list of dicts, the widget would use
yours instead of building its own.

Alternatively, you could override :meth:`_get_properties` to return
all the properties plus a reference to "total_sales".  Then the widget
should (hopefully) build its own colModel including your computed
column.  See here for _get_properties -> http://bit.ly/QSs8gA


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »