Configurable cell_class in DataTable

Bug #1229677 reported by Radomir Dopieralski
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Wishlist
Radomir Dopieralski

Bug Description

The behavior of DataTable's cells is currently very hard to change or extend. If I want to modify how data is presented, add a widget, icon, even just some style, I have basically two options: either put the HTML directly as the value of the cell, or create my own Row class, with a copy-pasted and slightly modified load_cells method. If I wanted to modify the behavior of any of the auto columns (for example, to make some of the checkboxes for multi select pre-selected), I don't even have a choice -- I have to make my own Row and copy most of its logic. Obviously that's not very nice -- copying the code also makes me copy any and all bugs that are there, and they will stay in the copy even when they are fixed in the original.

I want to propose two changes that should make it easier to extend the behavior of DataTable cells:
1. Move the logic for filling a cell with data into a separate method on the Cell class,
2. Add a cell_class option to DataTableOptions, allowing me to provide my own Cell class, which extends the original one.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

Fix proposed to branch: master
Review: https://review.openstack.org/48018

Changed in horizon:
assignee: nobody → Radomir Dopieralski (thesheep)
status: New → In Progress
Changed in horizon:
milestone: none → icehouse-2
importance: Undecided → Wishlist
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/49114
Committed: http://github.com/openstack/horizon/commit/fdf920e7149dc3547caa1a2cb1ea54930bfd3589
Submitter: Jenkins
Branch: master

commit fdf920e7149dc3547caa1a2cb1ea54930bfd3589
Author: Radomir Dopieralski <email address hidden>
Date: Tue Sep 24 11:15:31 2013 +0200

    Configurable cell_class in DataTable

    There are two changes in this proposal. One is to move the logic
    for extracting cell data from the row datum (and handling auto columns)
    to the Cell class, into a separate method for easy extending. The
    second is to make that extending possible by making the cell class
    configurable in the DataTable's meta.

    Those changes are supposed to make it easier to extend the DataTable
    with new kinds of cells -- for example, cells that contain an editable
    widget, a progress bar, an icon, etc. as well as make it easier to
    modify the behavior of the auto columns -- for example, by making it
    possible to have some of the multi_select checkboxes preselected. Those
    changes would also make it easier to integrate DataTable with a Django
    FormSet.

    Right now, in order to modify any of the proposed Cell.get_data
    behavior, one has to make their own Row class and practically copy-paste
    the whole Row.load_cells method, as there is no easy way to extend it.

    Change-Id: I29277a9e77e1c413193fe80d3f8cfe001bf5d709
    Closes-Bug: #1229677

Changed in horizon:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in horizon:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in horizon:
milestone: icehouse-2 → 2014.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.