Category Archives: Sencha

Salesforce Add Action To apex:enhancedList

There’s no quick way to add actions to the action column of an apex:enhancedList. Here’s the workaround.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<apex:page >
    <style>
    .x-grid3-dirty-cell {
        background-image: none;
    }
    </style>
    <script type="text/javascript">    
    function endsWith(str, suffix) {
        return str.indexOf(suffix, str.length - suffix.length) !== -1;
    }
    function setActions() {        
        Ext.ComponentMgr.all.each( function(item, index, length) {
            if(endsWith(item.id, "grid")) {                
                var action = '<a href="/apex/My_VisualForce_Page?id=%s"><span>My Action</span></a>';
                item.store.each( function(record) {
                    var id = record.id;
                    var temp = action;
                    temp = temp.replace("%s", id);
                    record.set("ACTION_COLUMN", [temp]);
                });
                item.store.on("load", function() {
                    item.store.each( function(record) {
                        var id = record.id;
                        var temp = action;
                        temp = temp.replace("%s", id);
                        record.set("ACTION_COLUMN", [temp]);
                    });
                });
            }
        });
    }
    </script>
    <apex:enhancedList type="Systems__c" height="300" oncomplete="setActions();" />
</apex:page>

Salesforce uses the Extjs framework (Sencha.com) to implement list views. All user interface components on an Extjs page are registered with a component manager. The code accesses the component manager, looks for a component whose id corresponds to a grid (our enhancedList), and then changes the action items in the store associated with the grid.

Sameoldreader is now DeliciouRSS

I updated the home page and a few other extras for my Delicious reader app: http://deliciourss.appspot.com/.

Here’s a screenshot of my Delicious account loaded:

Deliciourss App

Google App Engine released PHP support, which is a bummer since I developed the app in Python but would prefer PHP. Its still nice to learn Python. At some point I’ll add tracking of read articles and tracking of new articles.