Skip to content

Instantly share code, notes, and snippets.

@wabson
Created October 25, 2012 13:43
Show Gist options
  • Save wabson/3952617 to your computer and use it in GitHub Desktop.
Save wabson/3952617 to your computer and use it in GitHub Desktop.
Web script extension controller to add additional action(s) to data list items
<@link rel="stylesheet" type="text/css" href="${url.context}/res/myco/components/data-lists/sample-action.css" group="datalists" />
<@script type="text/javascript" src="${url.context}/res/myco/components/data-lists/sample-action.js" group="datalists"></@script>
if (model.widgets)
{
for (var i = 0; i < model.widgets.length; i++)
{
var widget = model.widgets[i];
if (widget.id == "DataGrid")
{
// These two lines only needed if you want to show the action in the 'actions' cell,
// otherwise a 'More actions' menu will be created to display it.
widget.options.splitActionsAt = 4;
widget.options.actionsColumnWidth = 105; // splitActionsAt * 25 + 5
// Add the action definition - this will be action-specific
model.actionSet.push({
id: "onActionSample", // Change to match your handler function name
type: "action-link",
permission: "",
href: "",
label: "actions.datalist.mycustom" // Change to match your custom label in datagrid.get.properties
});
}
}
}
# Custom action labels
actions.datalist.sample=My Sample Action
actions.datalist.sample.message=It works!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment