View Full Version : Grid Schema and XML Attributes
Domitian
5 Feb 2007, 6:06 PM
Does anyone know if you can include the attributes of an XML node in the schema declaration. For example the xml I'm retrieving has a node that has an additional attribute:
<reporter name="john doe">johndoe@hotmail.com</reporter>
So far, everything is working fine in my grid. When it reaches the reporter field it retrieves the email address which is to be expected. The behavior I'd rather retrieve is the name not the value of the reporter node (in this case, the email address). Is this possible?
tryanDLS
5 Feb 2007, 6:34 PM
Add a 'name' to your schema. The loadData fn looks at elements and attributes.
Domitian
5 Feb 2007, 6:38 PM
Dumb question, but expected since I just started using the Grid today, but how would I do that?
Here's my current schema
var schema =
{
tagName: 'bug',
id: 'bug_id',
fields: ['bug_id', 'bug_severity', 'reporter', 'priority', 'op_sys', 'assigned_to', 'bug_status', 'short_desc']
};
Note: not all the fields have a name, just the reporter field does.
tryanDLS
5 Feb 2007, 6:51 PM
I meant just add another field to your schema called 'name' which happens to be your attribute
var schema =
{
tagName: 'bug',
id: 'bug_id',
fields: ['bug_id', 'bug_severity', 'reporter', 'priority', 'op_sys', 'assigned_to', 'bug_status', 'short_desc', 'name']
};
Domitian
5 Feb 2007, 9:28 PM
I tried that earlier and nothing came back. I'm a little unsure how the system would know how to retrieve that value. What happens if another element has the attribute of name as well?
tryanDLS
6 Feb 2007, 7:49 AM
Can you post a better example of your xml- one complete main element at least. What I suggested works, unless there's an issue with the structure of your xml and the nesting.
Domitian
6 Feb 2007, 10:38 AM
Sure, no problem. Here's one element in my XML
<bug>
<bug_id>1</bug_id>
<creation_ts>2007-01-25 22:13</creation_ts>
<short_desc>Testing this out</short_desc>
<delta_ts>2007-01-25 22:13:19</delta_ts>
<reporter_accessible>1</reporter_accessible>
<cclist_accessible>1</cclist_accessible>
<classification_id>1</classification_id>
<classification>Unclassified</classification>
<product>TestProduct</product>
<component>TestComponent</component>
<version>unspecified</version>
<rep_platform>PC</rep_platform>
<op_sys>Windows</op_sys>
<bug_status>NEW</bug_status>
<priority>P5</priority>
<bug_severity>enhancement</bug_severity>
<target_milestone>---</target_milestone>
<everconfirmed>1</everconfirmed>
<reporter name="John Doe">johndoe@hotmail.com</reporter> <----trying to access here
<assigned_to name="John Doe">johndoe@hotmail.com</assigned_to>
<estimated_time>0.00</estimated_time>
<remaining_time>0.00</remaining_time>
<actual_time>0.00</actual_time>
−
<long_desc isprivate="0">
<who name="John Doe">johndoe@hotmail.com</who>
<bug_when>2007-01-25 22:13:19</bug_when>
<thetext>Testing</thetext>
</long_desc>
</bug>
tryanDLS
6 Feb 2007, 11:55 AM
It looks like it will only find attributes of top level node. I think this will change in the next version - I would imagine this is going to be done with DomQuery and it should be able to XPath type of searches.
Someone else may have another solution, but the best way might be to restructure the XML to use attributes - the way you are doing it imposes a big overhead for the amount of data vs wrapping text that has to be transmitted.
The other possibility would be to overload the loadData process to allow deeper searches/XPath queries - you'd probably also have to modify the logic that updates the underlying doc with the changes if you're going to edit in the grid.
Domitian
6 Feb 2007, 12:00 PM
Thanks Tim, this was the behavior that I thought it was exhibiting. I think I can live with just the top level nodes and change the code when XPathing is allowed. Does a feature request have to be made or does Jack already have this planned in the Roadmap? On another note, I was looking for information about remote datasets for the Grid. I know about the blob entry and it's sufficient from the client-side, but I was wondering what retooling needed to be done on the server side. I noticed that Jack had mentioned to someone that he would write something up on how code should be written for this, but I never found the entry. Any information concerning the retooling of the server would be most helpful. Thanks.
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.