Custom toolbar button in SalesLogix editable grids
Posted By: nicocrm on November 5th, 2011 in Saleslogix
No Gravatar

The new “Editable Grid” (introduced in SalesLogix 7.5.4) is most noticeable by its ability to be, well, editable. But it also has another interesting feature – the ability to make multiple selection in the grid and easily associate a button that will take an action over all the selected records. Prior to having this grid we had to do something like add a checkbox column and do some complex handling of postbacks to keep track of which items were selected (especially if the grid had several pages) but now all that is required is a little bit of Javascript that will leverage the power of the dojo grid and of sdata.

As a quick demonstration let’s create a grid that will have a button “Copy” that invokes a Copy business rule for each of the selected records. This is a simplistic example but you could apply the same logic to e.g. submit invoices, flag order line items, email contacts, etc. I created a new entity Widget, added a “Copy” business rules to it and added the tab on the account screen:

The copy business rule is quite simple, just doing a copy of the current record:


The last piece of the puzzle is the javascript code that will handle the click on the toolbar button, query the grid for the selected records, and call the business rule for each record.


The critical parts are probably this one, which asks the grid for the selection:

var selectedItems = grid.selection.getSelected();

and this one, which retrieves the value from one item (you can retrieve any value that is queried by the grid, not just the key):

var id = store.getValue(selectedItems[i], "$key");

The rest of the code is just concerned with looping through the items (I used a recursive function rather than a straight loop, to make it easier to detect when all the items were done) and invoking the business rule via sdata (you can find more details on that on the sdata javascript client wiki on Github).

This needs to be set as the “onclick” handler for the toolbar item:

As an aside – note the “onClick” dropdown expands to reveal an editor. When you paste text into this field, make sure you expand the editor, otherwise only the first line will be kept!

I have also uploaded a bundle containing the example code.

Leave a Reply