Skip to main content

Is it possible to add action to a row items in a dojo.table?

1 reply [Last post]
rayo
Offline
Joined: 2008-06-12
Points: 0

The idea is this one:
We have this json file for the dojo.table
{'name': 'Filtering Table',
'type': 'dojo',
'jmakiVersion' : '1.0',
'version' : '1.0',
'image' : 'images/dojo-table.jpg',
'description': 'This widget is storing table which you filter data for and add items.',
'args': [
],
'value': {
'required': true, 'type': 'OBJECT',
'defaultValue':{
'columns':[
{ 'label' : 'Title', 'id' : 'title'},
{ 'label':'Author', 'id' : 'author'},
{ 'label': 'ISBN #', 'id' : 'isbn'},
{ 'label': 'Description', 'id' : 'description'}
],
'rows':[
{ 'title' : 'Book Title 1', 'author' : 'Author 1', 'isbn': '4412', 'description' : 'A Some long description'},
{ 'id' : 'foo', 'title' : 'Book Title 2', 'author' : 'Author 2', 'isbn': '4412', 'description' : 'A Some long description'}
]
},
'description':'An object containing a object of colums and array of row arrays to be added to the table.'},
'config' : {
'type' :
{ 'id' : 'dojo',
'libs' : [
'../resources/libs/dojo/v0.4.3/djd43.js'
],
'preload' : 'if (typeof djd43_config ==\'undefined\') djd43_config = { parseWidgets: false, searchIds: [] };',
'resources' : [
'../resources/libs/dojo/v0.4.3/src'
]
}
}
}

I wouls like to make a row with the following contenet, the meanning is obious (I believe)
'rows':[
{ 'title' : 'Book Title 1', 'author' : 'Author 1', 'isbn': '4412', 'description' : 'A Some long description', 'action':'/loadnewurl', 'payload':[{'param1':'value1'},{'param2':'value2'}]},
{ 'id' : 'foo', 'title' : 'Book Title 2', 'author' : 'Author 2', 'isbn': '4412', 'description' : 'A Some long description'}
]

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
gmurray71
Offline
Joined: 2003-07-31
Points: 0

This could be done but will require a little glue code:

Try :

jmaki.subscribe("/table/select", function(args) {
// check for an action on the value of the select
if (args.value && args.value.action) {
// get the row the row id
var _targetId = args.value.id;
jmaki.processActions( {
targetId : _targetId,
widgetId : _args.widgetId,
action : args.value.action
});
}
});

Your actions in the rows should actually be formatted like:

'action' : { 'topic' : '/loadnewurl', 'message': [{'param1':'value1'},{'param2':'value2'}] }

Let me know if this doesn't work for you.

-Greg