我刚开始使用 javascript 和 jquery,对一切都一无所知。
这是我从模型转换而来的 json
changeData = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model));
内容如下所示:
changeData = [
{"RemoteRoute":{"Id":1,"Code":"1","Name":"Route1a","Outward":true,"Detail":null},"LocalRoute":null,"Change":"New"},
{"RemoteRoute":{"Id":1,"Code":"1","Name":"Route1b","Outward":false,"Detail":null},"LocalRoute":null,"Change":"New"},
{"RemoteRoute":{"Id":2,"Code":"2","Name":"Route2a","Outward":true,"Detail":null},"LocalRoute":null,"Change":"New"},
{"RemoteRoute":{"Id":2,"Code":"2","Name":"Route2b","Outward":false,"Detail":null},"LocalRoute":null,"Change":"New"}]
我用来创建一个表
for (var item in changeData){
var tr=$('<tr onclick=\"ShowChange(' + no + ');\" class=\"childDiv\"></tr>');
outward = changeData[item].RemoteRoute.Outward;
code = changeData[item].RemoteRoute.Code;
name = changeData[item].RemoteRoute.Name;
change = changeData[item].Change;
$('<td>'+ code +'</td>').appendTo(tr);
$('<td>'+ name +'</td>').appendTo(tr);
$('<td>'+ change +'</td>').appendTo(tr);
tr.appendTo('.displaytable');
};
我正在尝试使用 ajax 创建一个搜索框(用于“名称”)。但是,正如我上面所说,我从这里完全一无所知。
谁能建议我一些我可以采取的方法。一个例子会很棒。非常感谢!