...

View Full Version : Tabular Data Control



GrandpaB
06-15-2004, 01:35 AM
I have need to include Microsoft's Tabular Data Control into a web page I'm writing. Since the audience is 100% IE6, I'm not concerned by browser compatibility issues. The code for the page is fairly simple and works, but I'd like to make some modifications. Here is the page:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>My Art</title>
</head>

<body>
<strong>My Art</strong><br /><br />

<object id="sgwart" classid="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
<param name="DataURL" value="images/art.txt" />
<param name="UseHeader" value="TRUE" />
<!--param name="TextQualifier" value="~" /-->
<param name="FieldDelim" value="~" />
</object>

<table border="1" cellpadding="3" cellspacing="0" bordercolor="#999999" datasrc="#sgwart">
<thead><tr>
<td>Title</td>
<td>Description</td>
<td>Location</td>
<td>Size (W x H)</td>
<td>Height</td>
<td>Value</td>
<td>Appraisal</td>
<td>Picture</td>
</tr></thead>
<tbody><tr>
<td><div datafld="Title"></div></td>
<td><div datafld="Description"></div></td>
<td><div datafld="Location"></div></td>
<td><div datafld="Width"></div></td>
<td><div datafld="Height"></div></td>
<td><div datafld="Value"></div></td>
<td><div datafld="Appraisal"></div></td>
<td><div datafld="Picture"></div></td>
</tr></tbody>
</table>

</body>
</html>

The first modification is to combine the contents of the "Width" and "Height" fields into a single cell in the table called "Size (W x H)." This cell would display, for example, "36 x 45," where 36 and 45 came from the "Width" and "Height" fields.

The secong modification is to combine the contents of the "Title" and "Picture" fields into a single cell in the table. This cell would display, for example, "Blue Boy" where Blue Boy came from the "Title" field and the URL for the link came from the "Picture" field.

Your assistance in how this is done wwill be most appreciated; thanks GrandpaB

bnovc
06-15-2004, 02:29 AM
Umm...you highlight "Width" and click to the right of "Height" push your space bar, followed by ctrl+v.....

What do you want?



<?php
if(strpos($_POST['wandh'], 'x') !== false)
{
$split = explode('x', $_POST['wandh']);
$width = trim($split[0]);
$height = trim($split[1]);
}else
{
echo 'Invalid Format';
}
?>


Is that what you want? Should work...

neofibril
06-15-2004, 03:46 AM
This wouldn't seem to require any scripting.
Here's a simple xml example:



<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>My Art</title>

<xml id="sgwart">
<?xml version="1.0"?>
<art>
<work>
<title>Title 1</title>
<url>#</url>
<description>Description 1</description>
<location>Location 1</location>
<width>W1</width>
<height>H1</height>
<value>Value 1</value>
<appraisal>Appraisal 1</appraisal>
</work>
<work>
<title>Title 2</title>
<url>#</url>
<description>Description 2</description>
<location>Location 2</location>
<width>W2</width>
<height>H2</height>
<value>Value 2</value>
<appraisal>Appraisal 2</appraisal>
</work>
<work>
<title>Title 3</title>
<url>#</url>
<description>Description 3</description>
<location>Location 3</location>
<width>W3</width>
<height>H3</height>
<value>Value 3</value>
<appraisal>Appraisal 3</appraisal>
</work>
</art>
</xml>
<style type="text/css">
td
{
text-align:center;
}
caption
{
text-align:left;
font-weight:bold;
}
</style>
</head>
<body>
<table
border="1" cellpadding="3" cellspacing="0"
bordercolor=" 999999" datasrc="#sgwart">
<caption>My Art</caption>
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th>Location</th>
<th>Size (W x H)</th>
<th>Value</th>
<th>Appraisal</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a datafld="url">
<span datafld="title"></span>
</a>
</td>
<td>
<div datafld="description"></div>
</td>
<td>
<div datafld="location"></div>
</td>
<td>
<span datafld="width"></span>
&nbsp;x&nbsp;
<span datafld="height"></span>
</td>
<td>
<div datafld="value"></div>
</td>
<td>
<div datafld="appraisal"></div>
</td>
</tr></tbody>
</table>
</body>
</html>

GrandpaB
06-15-2004, 04:32 PM
First, my thanks to both Bnovc and Neofibril. Your responses highlight that I'm still on the steep part of the HTML/JavaScript learning curve. However, since I know nothing of PHP (barely how to spell it) I'm concentrating on Neofibril's response.

Your suggestion to change the <div> tags to <span> tags allowed me to successfully display the "Width" and "Height" fields of my data source in a single cell of my table.

I am however having difficulty combining the contents of the "Title and "Picture" fields into a cell that is a link. Your code:

<td><a datafld="url"><span datafld="title"></span></a></td>

does not work because the contents of the "Picture" field is not the complete URL. The "Picture" field only contains the name of a picture file, ie "blueboy.jpg." The complete URL is "images/blueboy.jpg." How do I combine "images/" with datafld="Picture" to create the complete URL.

I have attempted as many combinations as I can think of without success.

Thanks in advance for your assistance, GrandpaB

neofibril
06-15-2004, 04:45 PM
The easiest thing might be to place something like <base href="http://mySite.foo/images/"/> in the <head> section.

Will that work for your purposes?

GrandpaB
06-15-2004, 05:09 PM
It sounds like a cool solution. I did not want to get into a long winded explanation of this application, but it will not be web based; it will run on a local network. Instead of using "http:" I used "file:" Here is one of several attempts to get the code right.

<base href="file://C:\Documents and Settings\Bernie\My Documents\Art\images"/>

If you have any other suggestions I'd be most appreciative, in the mean time I'm searching my help files.

GrandpaB

PS Your response was almost immediate. Hopefully your have a life other than answering the questions of a newbie. ;)

neofibril
06-15-2004, 05:39 PM
Try this.



<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>My Art</title>

<script type="text/javascript">
function isTabulated()
{
tabulator.readyState == "complete" ? setBaseRefs() : setTimeout(isTabulated, 100);
function setBaseRefs()
{
var i = 0, a = tabulator.all.tags("A");
for (; i < a.length; i++)
a[i].href = "file://C:\\Documents and Settings\\Bernie\\My Documents\\Art\\images\\" + a[i].nameProp;
}
}
</script>

<xml id="sgwart" ondatasetcomplete="isTabulated()">
<?xml version="1.0"?>
<art>
<work>
<title>Title 1</title>
<url>picture1.gif</url>
<description>Description 1</description>
<location>Location 1</location>
<width>W1</width>
<height>H1</height>
<value>Value 1</value>
<appraisal>Appraisal 1</appraisal>
</work>
<work>
<title>Title 2</title>
<url>picture2.gif</url>
<description>Description 2</description>
<location>Location 2</location>
<width>W2</width>
<height>H2</height>
<value>Value 2</value>
<appraisal>Appraisal 2</appraisal>
</work>
<work>
<title>Title 3</title>
<url>picture3.gif</url>
<description>Description 3</description>
<location>Location 3</location>
<width>W3</width>
<height>H3</height>
<value>Value 3</value>
<appraisal>Appraisal 3</appraisal>
</work>
</art>
</xml>
<style type="text/css">
td
{
text-align:center;
}
caption
{
text-align:left;
font-weight:bold;
}
</style>
</head>
<body>
<table
border="1" cellpadding="3" cellspacing="0"
bordercolor="#999999" datasrc="#sgwart" id="tabulator">
<caption>My Art</caption>
<thead>
<tr>
<th>Title</th>
<th>Description</th>
<th>Location</th>
<th>Size (W x H)</th>
<th>Value</th>
<th>Appraisal</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a datafld="url">
<span datafld="title"></span>
</a>
</td>
<td>
<div datafld="description"></div>
</td>
<td>
<div datafld="location"></div>
</td>
<td>
<span datafld="width"></span>
&nbsp;x&nbsp;
<span datafld="height"></span>
</td>
<td>
<div datafld="value"></div>
</td>
<td>
<div datafld="appraisal"></div>
</td>
</tr>
</tbody>
</table>
</body>
</html>

neofibril
06-15-2004, 06:00 PM
PS Your response was almost immediate. Hopefully your have a life other than answering the questions of a newbie. ;)

Although the timing was coincidental, I appreciate your concern there, grandpa.

That is unreal. I'll try not to reply so soon next time, or not at all. ;)

GrandpaB
06-15-2004, 10:15 PM
The XML solution seems to move me away from the Tabular Data Control with which I started. Is there a way, a non-XML way to concatenate the string "images/" with the datafld="Picture" so that they form a link?

<td>
<a href="image/"+datafld='Picture'>
<span datafld="Title"></span>
</a></td>

OR,

<td>
<a href="'image/+<span datafld='Picture'></span>">
<span datafld="Title"></span>
</a></td>

Somehow I feel that a solution lays somewhere between the <span> and <div> tags, the double and single quotes. Am I wrong?

GrandpaB

neofibril
06-16-2004, 03:01 AM
The inline xml was just for demonstration.

For use with the TDC, call the function like so: <body onload="isTabulated()">



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum