logo       

Re: dwr.util: msg#00185

java.dwr.user

Subject: Re: dwr.util

As possible solution, you can use use the following
rowCreator to 'associate' item id with row:

myRowCreator = function(options) {
var row = document.createElement("tr");
row.itemId = options.data.myId;
return row;
}

Row creator will produce DOM element as if you write:
<tr itemId="123">
...
</tr>

Next, you need to enable onclick handler for rows, and
here is how it can be done with use of prototype.js
framework:

function createAndDecorateTable(myData) {
var myTableElem = $("myTableId");
DWRUtil.removeAllRows(myTableElem);
DWRUtil.addRows(myTableElem, myData, myCellFn,
{rowCreator: myRowCreator, someOtherOption:
valueOfSomeOtherParams, ..});
myTableElem.onclick = myOnClickFn;
}

/** onclick handler for whole table */
function myOnClickFn() {
//travers DOM from element where onclick occured up
to enclosing TR element
var rowClicked = Event.findElement(event, "tr");
if (rowClicked && rowClicked.itemId) {
doSomething(rowClicked.itemId);
}
}

/** biz logic you need to do with id */
function doSomething(id) {
// do something..
}

--- Shane Sheridan <sheridanshane-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx>
wrote:

> Hi,
>
> I am currently generating rows in a table using
> DWRUtil.addRows function which
> is working fine but ive recently got new
> requirements that require me to give
> each tr a 'onclick' event and an 'id'. Does anyone
> know how i would do this?? I
> know it involves the rowCreator function but i
> cannot seem to set these
> attributes using this function?
>
> Any responses would be greatly appreciated.
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe-EyPigyGktj4FDOXUYO6UHQ@xxxxxxxxxxxxxxxx
> For additional commands, e-mail:
> users-help-EyPigyGktj4FDOXUYO6UHQ@xxxxxxxxxxxxxxxx
>
>




____________________________________________________________________________________
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives.
http://tools.search.yahoo.com/toolbar/features/mail/


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise