html:
<div id="grid"></div>
js:
$("#grid").datagrid({
width: 600,
height: 400,
columns: [
{ text: "名称", field: "name", width: 200 },
{ text: "年龄", field: "age" },
{ text: "日期", field: "birthday",
renderer: function (value, row, col) { if (value &&value.getFullYear) {
value = value.getFullYear() + "-" + (value.getMonth() + 1) + "-" + value.getDate()
} return value
}
}
],
data: [
{ name: "name1", age: 20, birthday: new Date() },
{ name: "name1", age: 20, birthday: new Date() },
{ name: "name1", age: 20, birthday: new Date() },
{ name: "name1", age: 20, birthday: new Date() },
{ name: "name1", age: 20, birthday: new Date() }
]
}) function addRow() { var grid = $("#grid").data("datagrid")
grid.addRow({ name: "bbb" })
} function setColumns() {
var grid = $("#grid").data("datagrid")
grid.setColumns([
{ text: "Name", field: "name", width: 150 },
{ text: "Age", field: "age", width: 150 }
])
}
<body><button id="addform"></button></body> $(function(){$("#addform").click(function(){
var form = $("<form></form>")
var select = $("<select></select>")
var option1 = $("<option>1</option")
var option2 = $("<option>2</option")
var option3 = $("<option>3</option")
select.append(option1)
select.append(option2)
select.append(option3)
var input = $("<input type='text'/>")
form.append(select)
form.append(input)
$("body").append(form)
})
})
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)