2 html javascript c# jquery dhtmlx
我有2列dhtmlx grid table.我想dropdown menu为每个单元格填充第二列.
我生成xml document的C#
该generated xml文件在C#:
<rows>
<head>
<column type="ed" width="205" sort="str">Product</column>
<column type="co" width="205" sort="na" id="last">Class</column>
</head>
<row id="1">
<cell>Product_name_1</cell>
<cell>
<select>
<option id="1" value="1">first_option</option>
<option id="2" value="2">second_option</option>
</select>
</cell>
</row>
<row id="2">
<cell>Product_name_2</cell>
<cell>
<select>
<option id="3" value="4">first_option</option>
<option id="4" value="4">second_option</option>
</select>
</cell>
</row>
</rows>
Run Code Online (Sandbox Code Playgroud)
Html并且Javascript code:
<body>
<div id="mygrid_container" style="width:1026px;height:500px"></div>
<script>
var mygrid;
$(document).ready(function () {
$.ajax({
url: "/Admin/XMLForProducts",
dataType: "json",
type: "GET",
data: {},
success: function (result) {
mygrid = new dhtmlXGridObject('mygrid_container');
mygrid.init();
mygrid.parse(result, "xml");
}
});
});
</script>
</body>
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我只是在第一列填充值(Product_name_1和Product_name_2),我没有得到第二列的每个单元格的下拉菜单,我不知道如何解决这个问题.
小智 5
代替:
<cell>
<select>
<option id="3" value="4">first_option</option>
<option id="4" value="4">second_option</option>
</select>
</cell>
Run Code Online (Sandbox Code Playgroud)
你需要:
<cell><![CDATA[<select><option id="3" value="4">first_option</option><option id="4" value="4">second_option</option></select>]]></cell>
Run Code Online (Sandbox Code Playgroud)
以下是关于在xml中处理特殊字符的教程:http://docs.dhtmlx.com/doku.php? id =其他:特殊字符_字符 _in_xml
在这里你可以找到一个现成的例子:
和教程:http://docs.dhtmlx.com/doku.php?id = ddtmlxgrid : how_to_use_new_excell_combo