Skip to main content

Delete a row from a dojo table

3 replies [Last post]
dinamlab
Offline
Joined: 2005-09-20

Hi.... Im trying to use a dojo table, but I want to an action on right click of mouse, or if selected a row some button to delete the selected row of a specific table, how can I do that its posible?... im seeing the javascript of the dojo.table buth i dont see a function to delete a row from a table

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
dinamlab
Offline
Joined: 2005-09-20

Hi what if I add something to dojo/table/component.js, something like the etable component script where I define the widget.

[code]
jmaki.namespace("jmaki.widgets.dojo.table");

dojo.require("dojo.date.format");
dojo.require("dojo.math");
dojo.require("dojo.collections.Store");
dojo.require("dojo.html.*");
dojo.require("dojo.html.util");
dojo.require("dojo.html.style");
dojo.require("dojo.html.selection");
dojo.require("dojo.event.*");
dojo.require("dojo.widget.*");
dojo.require("dojo.widget.HtmlWidget");

dojo.widget.defineWidget("dojo.MyFilteringTable", dojo.widget.HtmlWidget, function () {....

//and modifying the onSelect function

onSelect:function (e) {
var row = dojo.html.getParentByType(e.target, "tr");
if (dojo.html.hasAttribute(row, "emptyRow")) {
return;
}
var body = dojo.html.getParentByType(row, "tbody");
if (this.multiple) {
if (e.shiftKey) {
var startRow;
var rows = body.rows;
for (var i = 0; i < rows.length; i++) {
if (rows[i] == row) {
break;
}
if (this.isRowSelected(rows[i])) {
startRow = rows[i];
}
}
if (!startRow) {
startRow = row;
for (; i < rows.length; i++) {
if (this.isRowSelected(rows[i])) {
row = rows[i];
break;
}
}
}
this.resetSelections();
if (startRow == row) {
this.toggleSelectionByRow(row);
} else {
var doSelect = false;
for (var i = 0; i < rows.length; i++) {
if (rows[i] == startRow) {
doSelect = true;
}
if (doSelect) {
this.selectByRow(rows[i]);
}
if (rows[i] == row) {
doSelect = false;
}
}
}
} else {
this.toggleSelectionByRow(row);
}
} else {
//this line added
//here
//aqui
this.onSelectRow(row);

this.resetSelections();
this.toggleSelectionByRow(row);
}
this.renderSelections();
}

[/code]

and on the namespace of jmaki.widgets.dojo.table.Widget

modify this line for the table created before

and adding a function that publish an event

[code]

table = dojo.widget.createWidget("MyFilteringTable",{valueField: "Id"},container);

this.onSelectRow(row){
jmaki.publish(topic, {src: uuid, row: row});
}
[/code]

Im doing this but when I run it i have this message

Unable to create an instance of jmaki.widgets.dojo.table.Widget. See the error log for more detials

Any Ideas

Message was edited by: dinamlab

dinamlab
Offline
Joined: 2005-09-20

hi im been looking in component.js of dojo table, i found that this widget does not publish to any topic, how can I do to publish the selected row?

Im been thinking in something like this...

befor the init function end

[code]
table.store.setData(data);

//added to get table row

dojo.event.connect(table, "onSelect", self, "onSelect");

//here ends the init function
}
[/code]

next on the jmaki.widgets.dojo.table.Widget to add this function

[code]

this.onSelect = function(){
jmaki.publish(topic);
}
[/code]

but I have the same results, how can I conect the dojo event with jmaki publish?

dinamlab
Offline
Joined: 2005-09-20

I got this....

its a jmaki jsf... direcciones service give me a json array... it constructs ok

i want to glue.js...

[code]jmaki.addGlueListener({topic: "/dojo/table/direcciones", action: "call", target: {object: "jmaki.listeners.tableDirecciones",functionName:"direcciones"}});

jmaki.listeners.tableDirecciones = {

direcciones : function(selected){
alert(selected.row);
alert(selected.value);
}
}[/code]

But it does not display anything in the alert....

S|