[ 5 posts ]

Cai Guo Bin

  • Username: caigb
  • Joined: Wed Jul 11, 2012 10:08 pm
  • Posts: 33
  • Offline
  • Profile

How to extend a Datatable?

Post Posted: Tue Oct 30, 2012 9:30 pm
+0-
I am doing a little work on DataTable that I want to seal some logics into DataTable.
When I extend a DataTable like this:
Code:
     function TestTable(config) {
        TestTable.superclass.constructor.apply(this, arguments);
    };
    TestTable.NAME = "TestTable";
    Y.extend(TestTable, Y.DataTable);
    Y.TestTable = TestTable;


And then in page I call like this:
Code:
        var table = new Y.TestTable({
            columns: ......
            scrollable: 'y',
            height: '560px',
            data: ports
        }).render('#dtable');

It shows the table and data, but not with the right view style, if I just call new Y.DataTable, that view show fine.
What is the problem? Did I miss something to do with TestTable?

John Lindal

YUI Contributor

  • Username: jafl
  • Joined: Mon Nov 02, 2009 2:33 pm
  • Posts: 352
  • Location: Los Angeles, CA
  • Twitter: jafl5272
  • GitHub: jafl
  • Gists: jafl
  • Offline
  • Profile
Tags:

Re: How to extend a Datatable?

Post Posted: Mon Nov 05, 2012 8:54 am
+0-
Check the classes that are being set on the boundingBox and contentBox. If you change NAME, then I think you will get yui3-TestTable instead of yui3-datatable

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile
Tags:

Re: How to extend a Datatable?

Post Posted: Mon Nov 05, 2012 9:26 am
+0-
Jafl,

If that were the case, it would be a bug. The boundingBox has classNames derived from the NAME property in all the classes in the inheritance chain, thus, no styles are lost in the subclasses.

If this should happen it might be a bug often due to using the className of the contentBox, which is derived from only the last descendant, instead of that of the boundingBox or classNames generated dynamically using the latest NAME.

Whichever the case, it would be good to report it as a bug as styling is not meant to be redone from scratch when subclassing but overridden if required.

Alberto Santini

YUI Contributor

  • Offline
  • Profile
Tags:

Re: How to extend a Datatable?

Post Posted: Mon Nov 05, 2012 12:58 pm
+0-
Hello.

Duplicate:
viewtopic.php?f=18&t=10925

Regards,
Alberto

Luke Smith

YUI Contributor

  • Username: lsmith
  • Joined: Thu Aug 28, 2008 7:50 am
  • Posts: 511
  • Location: Sunnyvale
  • Twitter: ls_n
  • GitHub: lsmith
  • Gists: lsmith
  • IRC: ls_n
  • YUI Developer
  • Offline
  • Profile

Re: How to extend a Datatable?

Post Posted: Wed Dec 19, 2012 10:53 am
+0-
Satyam, I don't think that's correct. Widgets use `this.getClassName('foo')` to assign css classes to their DOM components, which derives from the class's NAME. Subclasses that override the NAME are expected to produce css classes that don't match the sam skin.

While I think it would be convenient for subclasses to retain styling by default, I don't know how to reconcile that with the current use of getClassName(), since the method exists on Widget.prototype specifically to generate NAME specific class names.

caigb,
There's probably no real need for you to assign a new NAME to your DT subclass, since it is used only for event prefixing and css classname generation. You can Y.Base.create('datatable', Y.DataTable.Base, [...]) all you'd like without conflicting with core DT classes or instances.
  [ 5 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum