Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reference Data Island Node from the HTML Element

Status
Not open for further replies.

simonB2006

Programmer
Jan 11, 2006
11
EU
k,
I have a Data Island.
Each record is displayed in table format, with 1 record taking up 2 rows.

Col1 Col2 Col3
Row1 R1 F1 R1 F2 Nested Sub-Table
Row2 R1 F3 R1 F4 ""
-----------
Row3 R2 F1 R2 F2 Nested Sub-Table
Row2 R2 F3 R2 F4 ""
---- etc etc

The nested table holds child-records where there may be many children to each main record.

I want the user to add new children to each main record.

My problem is in passing seomthing back to Javascript to represent the clicked node. i.e how to know which main record is in focus.

... what I am looking for is :
'the-XMLnode-responsible-for-this-HTML-element'

i have issues using rowIndex, and issues with passing back a unique reference number for each main record. What i really want is to pass the XML node object from the onclick, to my Javascript function

But all my attempts so far, return HTML DOM info, not XML.



Does that make sense ??

Many thanks







 
I would say as a start add an onclick, or whatever appropriate event, handler to each row and pass the self reference to it?
[tt]
<tr onclick="handler(this)">
[/tt]
Then the handler look like this.
[tt]
function handler(obj) {
var n=(obj.rowIndex\2)+1;
alert("The data in the row are from xml record of R"+n); //just for illustration
//all other material work follows suit
}
[/tt]
 
Amendment
Mixed up with vbs syntax without noticing! The line should be read like this.
[tt] var n=Math.floor(obj.rowIndex/2)+1;[/tt]

 
A data-island is HTML, not XML. Whats wrong with using the HTML DOM? What you trying to achieve?

Post some code. I would stay clear of using data-islands.

Jon

"I don't regret this, but I both rue and lament it.
 
I was using data islands because i'd seen them mentioned around and thought i'd try them ... see what they had to offer.
Impressed with the easy of displaying data, saves a lot of coding.
That's where the benefits seem to stop for me so far.

Before XML, i would import my data via delimated string, and for each record, create a new instance of my own JScript object holding all field details (plus giving that object any additional functionality i desired).

When i populated the display with a record, i could reference display=record ... making the two items (data and display) pretty much synonymous.

With data islands i seem to loose this functionality. I want to be able to click on a display (HTML) item and easily gain access to all the data available in the original data record. If possible, add methods and additional attributes to the record as well.

Maybe I am asking a lot, but there seems to be no reliable reference between HTML and XML at all with islands ?
 
I think I'm gonna need to see some code to be able to help you out. Post the whole thing if not too big, else just the important parts (display table structure, data-island and javascript)

Jon

"I don't regret this, but I both rue and lament it.
 
k, what i'll do is throw a simplified version together to avoid any unecessary headaches all round, will try get done this evening (UK)..

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top