Skip to main content

JMaki table and customized right-menu click on table data

1 reply [Last post]
sureshraju
Offline
Joined: 2007-05-11
Points: 0

Hi,

I have part of my web UI that is JMaki Table and its content are generated by by server and posted to jmak-table by JSON.

Now I want to have customized right-click option on JMaki-table data.

Any ideas on how to attach "right-mouse click" menu to JMaki table?

Thanks

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

You can do so with a little work.

You will need to add the following to the /resources/dojo/component.js

this.onSelect = function(e) {

var selected = [];
for (var i=0; i < self.rows.length; i++) {
if (table.isIndexSelected(i)) {
selected.push(i);
}
}
jmaki.publish(topic + "/onSelect", { id : wargs.uuid, type : 'onslect', selectedRows : selected, event : e });

}

this.postLoad = function() {
djd43.event.connect(table, "onSelect", self, "onSelect"); // if you are using .9.4 you will need to swap dj43 with 'dojo'
}

This will wire all onSelect events to be published to the topic of the widget (default is "/dojo/table")

In your glue code (glue.js) you can then have code to create a context menu:

jmaki.addGlueListener("/dojo/table/*", function(payload) {
jmaki.debug = true;
jmaki.log("Table on Select Event: " + payload);
});

The payload.event is the mouse event which you can get the x and y coordinates of off and create the context menu.

jMaki currently does not have a context menu but their is a dojo context menu I believe. You could also pretty easily create a floating div at the mouse point.

I am adding the event above to the jMaki .9.5 so you won't need to add this to the component if you get that release (hopefully we will have it out 07/13/2007).

Let us know if this does not work.