YUI 2.5。从XML填充下拉列表 [英] YUI 2.5. Populating a dropdown from XML

查看:138
本文介绍了YUI 2.5。从XML填充下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前正在编辑使用YUI 2.5和Perl构建的应用程序。我需要从xml文件中填充一个下拉列表,根据节点的属性,仅使用特定的行。不幸的是,在YUI 2.5中没有DropdownCellEditor小部件(据我所知,这直到2.6(?)才进入)。有没有人有任何想法?

Currently editing an application built using YUI 2.5 and Perl. I need to populate a dropdown from an xml file, and only specific rows are to be used depending on the attributes of the node. Unfortunately, there isn't the DropdownCellEditor widget in YUI 2.5 (as far as I'm aware, this didn't come in until 2.6(?)). Does anyone have any ideas?

我想我应该更新YUI,因为在这个非常旧的版本中,似乎有很多有用的功能缺失。原始开发人员使用的代码非常复杂,所以这是我最后一次尝试!任何建议将不胜感激...

I'm thinking I should probably just update YUI as there seems to be a lot of useful functionality missing in this very old version. The code the original developer is using is very convoluted, so this is my last try! Any advice would be greatly appreciated...

推荐答案

只是把任何人都卡住了类似的东西,我设法填充下拉菜单从XML文件如下:

Just incase anyone else is stuck with something similar, I managed to populate the dropdown from an XML file as follows:

//create function to read XML
function loadXMLDoc(dname)
{
if (window.XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else
{
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",dname,false);
xhttp.send();
return xhttp.responseXML;
} 

// load xml file
xmlDoc=loadXMLDoc('xmlsource.asp' + gameid);

teamnames =[];
var teams = xmlDoc.getElementsByTagName("hometeams");
for (var i = 0; i < teams.length; i++) {

var hname  = teams[i].getAttribute("name");
teamsnames.push(hname);
}

然后在列定义中:

var eventColumnDefs = [
{key:"teamname", sortable:true, editor:"dropdown", editorOptions:{dropdownOptions:teamnames}}
];

我希望这有助于某人。谢谢Satyam的帮助,这个和我的另一个问题。 =]

I hope this helps someone. Thank you Satyam for your help on this and my other question. =]

这篇关于YUI 2.5。从XML填充下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆