AUI RESTful table refreshing

Hi

I create AUI RESTful table in the following way:

    TestTable = new AJS.RestfulTable({
        el: $testTable,
        editable: false,
        allowEdit: false,
        allowReorder: false,
        loadingMsg: "Loading you table...",
        allowCreate: false,
        url: contextPath + "/rest/test/1.0/test",
        entries: test, // is not being picked up by restfultable, hack below
        resources: {
            all: contextPath + "/rest/test/1.0/test"
            self: contextPath + "/rest/test/1.0/test"
        },
        columns: [
            {
                id: "id",
                header: "name"
            },
            {
                id: "description",
                header: " description "
            },
            {
                id: "flag",
                header: " flag "
            }
        ]
    });
    for (var i = 0; i < test.length; i++) {
        TestTable.addRow(test[i]);
    }
    JIRA.userhover($testTable);

When user will update flag’'s value of one row, then flag’s value of other rows will change (rest api “put” changes flag’s value on server side). In this moment I need refresh restful table. But I can’t found how to do it in documentation, google and browse’s debugger. Can you help me?

1 Like

Hey Atlassian – Why do you just ignore these questions? Your components are undocumented and broken.

Hi @ftana @sfbehnke, thanks for the question, and thank you for bumping this topic back in to view for me.

This is a deceptively tricky thing. AUI’s RestfulTable component was built around Backbone v0.3 days, so unfortunately it does not always play nicely with or work using the Backbone conventions you might expect from Backbone v1.0+.

I have built a demo of how you can refresh rows in your table here, along with some small code commentary to explain what each part is about.

The short answer is: if you have access to the restfultable instance – var rt = AJS.RestfulTable(...) – you can call rt.getRows() to get access to each individual AJS.RestfulTable.Row that’s currently rendered to screen. On each of these views, you can call the AJS.RestfulTable.Row#refresh function, which will invalidate the row’s local state and re-fetch it from the server.

I’d be interested in knowing what else you tried, or what kind of methods/functions/events you would expect to see in the documentation or examples? The whole RestftulTable component could do with a refactor to conform to Backbone v1.3 conventions. I could schedule such an effort and take in to account your expectations. Would this be the most pressing issue in your UI development efforts, or are there other higher priority problems or difficulties in your UI development efforts?

Hope that helps,
Daz.

1 Like