[gradebook2-dev] Refreshing the column headers

Pang, David dxp at umich.edu
Fri Sep 24 09:15:26 PDT 2010


HI Thomas,

I have added a global variable ("showWeightedString") to present the toggle button status. After I made the change to display the headline at the buildColumn (see below):

-----------code start-------------
    private ColumnConfig buildColumn(Gradebook selectedGradebook, Item item, Configuration configModel) {
        boolean isHidden = configModel.isColumnHidden(AppConstants.ITEMTREE, item.getIdentifier(), true);
        StringBuilder columnNameBuilder = new StringBuilder().append(item.getName());

        Item gradebookItemModel = selectedGradebook.getGradebookItemModel();
        GradeType gradeType = gradebookItemModel.getGradeType();

        if (gradeType != null) {
            switch (gradeType) {
                case POINTS:
                   if (showWeightedString.equals("true"))
                        columnNameBuilder.append(" [").append(item.getPercentCourseGrade()).append("%]");
                    else
                       columnNameBuilder.append(" [").append(item.getPoints()).append("pts]");
                   break;
                case PERCENTAGES:
                    columnNameBuilder.append(" [%]");
                    break;
                case LETTERS:
                    columnNameBuilder.append(" [A-F]");
                    break;
            }
        } else {
            GWT.log("Grade Type is null for some reason", null);
        }
        ...
-------code end---------


It works, but only when item(s) get updated on the left panel.  How to create the re-init method to force the headline to reload along with grid data change?

Thanks,

David


PS: Can you add me (dxp at umich.edu) and Jim (jimeng at umich.edu) to the gradebook2-dev at collab.sakaiproject.org mail list.




From: Jim Eng <jimeng at umich.edu>
Date: August 31, 2010 6:34:49 PM EDT
To: Thomas Amsler <tpamsler at ucdavis.edu>
Cc: gradebook2-dev at collab.sakaiproject.org, sams at ctools.umich.edu
Subject: Re: [gradebook2-dev] Refreshing the column headers

Thanks, Thomas.  And thanks, Mike.  I think your responses to both issues will give David the info he needs.  And he will follow up with more questions if need be.

Jim


On Aug 31, 2010, at 6:18 PM, Thomas Amsler wrote:

The column headers are constructed in MultiGradeContentPanel's buildColumn(...) method:
ColumnConfig config = new ColumnConfig(id, name, columnWidth);

where the name is something like HW 1 [100pts].

You can overwrite this by getting the ColumnConfig objects from the grid. Since your functionality is a toggle, you probably want to restore the original column header titles. Here is some sample code:
e.g.

Class Member: private  Map<String, String> columnConfigBackup = null;

private void changeColumnConfigHeaders() {
    columnConfigBackup = new HashMap<String, String>();
    List<ColumnConfig> columnConfigs = grid.getColumnModel().getColumns();
    for(ColumnConfig columnConfig : columnConfigs) {
        if(columnConfig.getId().matches("[+-]?[0-9]+")) {
            columnConfigBackup.put(columnConfig.getId(), columnConfig.getHeader());
            columnConfig.setHeader("something");
        }
    }
}

private void restoreColumnConfigHeaders() {
    for(String id : columnConfigBackup.keySet()) {
        grid.getColumnModel().getColumnById(id).setHeader(columnConfigBackup.get(id));
    }
}

Let me know if this works.

Best,
-- Thomas

On Mon, Aug 30, 2010 at 5:56 PM, Jim Eng <jimeng at umich.edu> wrote:
As part of David's work on GRBK-483, he would like to refresh the column headers.  I think Thomas or Michael said there was a bug in 1.2.x that made that harder, but it would be fixed in 1.3.x. Is that correct?  I think David has already written code that puts corrected values in the header cells (corrected to fit the updated context), but they are not showing up. Can you tell us what method call in the event handler would cause the headers to refresh?

Thanks.

Jim


_______________________________________________
gradebook2-dev mailing list
gradebook2-dev at collab.sakaiproject.org
http://collab.sakaiproject.org/mailman/listinfo/gradebook2-dev


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/gradebook2-dev/attachments/20100924/976c1373/attachment-0001.html 


More information about the gradebook2-dev mailing list