How to Display the Selected Item from Database in Kendo Grid while click the Edit Button My Coding Like
var grid= $("#DivUser").kendoGrid(
{
dataSource: DataSource4,
scrollable: true,
sortable: true,
filterable: false,
reorderable: true,
resizable: true,
pageable: true,
toolbar: [ { text : "Add new record", name: "popup",
iconClass: "k-icon k-add"} ],
editable : {
mode : "inline"
columns: [
{
field: "LoginName",
title: "Login Name",
width:"175px"
},
{
field: "ScopeId",
title: "Scope Id",
editor: ScopeDropDownEditor
},
{
command: ["edit", "destroy"],
title: " ",
width: "175px"
}
]
}).data("kendoGrid");
var DataSourceScope = new kendo.data.DataSource(
{
transport: {
读取: {
网址:"WebServices/Project.asmx/GetScope", 数据:"{}",
contentType:'application/json; charset=utf-8', 类型:'POST',
dataType:'json' },
parameterMap:function(options,operation) {
if(operation == 'read') return kendo.stringify(options);
} },
架构: {
data:function(Data) {
return(Data.d); },
型号: {
id:"ScopeId", fields:
{ ScopeId:{type:"number"},
ScopeName:{type:"string"} }
} },
错误:function(e) { `<br>` var xhr = e [0];
var statusCode = e [1]; var errorThrown = e [2];
alert('DataSourceScope - ' xhr ', ' statusCode ', ' errorThrown); } `<br>` });
function ScopeDropDownEditor(container,options) {
$(' data-bind= 668222 />') .appendTo(container)
.kendoDropDownList( {
autoBind:false, dataSource:DataSourceScope
}); `` }`
在我的webservice代码中
public class Scopes
{
int _ScopeId;
string _ScopeName;
public int ScopeId
{
get { return _ScopeId; }
set { _ScopeId = value; }
}
public string ScopeName
{
get { return _ScopeName; }
set { _ScopeName = value; }
}
public Scopes() { }
public Scopes(int ScopeId, string ScopeName) { this.ScopeId = ScopeId; this.ScopeName = ScopeName; }
}
[WebMethod]
public List<Scopes> GetScope()
{
string StrConnectionString = ConfigurationManager.ConnectionStrings["sample"].ConnectionString;
SqlConnection SqlConnection1 = new SqlConnection(StrConnectionString);
SqlCommand SqlCommand1 = new SqlCommand("select distinct ScopeId,(select ScopeName from Scope2 where Scope2.ScopeID=User2.ScopeId)as ScopeName from User2", SqlConnection1);
DataTable DataTable1 = new DataTable();
SqlDataAdapter SqlDataAdapter1 = new SqlDataAdapter(SqlCommand1);
SqlDataAdapter1.Fill(DataTable1);
List<Scopes> ListScope = new List<Scopes>();
foreach (DataRow DataRow1 in DataTable1.Rows)
{
ListScope.Add(new Scopes(Convert.ToInt32(DataRow1["ScopeId"]), Convert.ToString(DataRow1["ScopeName"])));
}
return ListScope;
}
这是好的..但是点击编辑按钮之后的下拉列表项目就像第一项一样
ScopeName id下拉列表项Admin,Developer,tester
在数据库中,james是测试器,如果我单击编辑按钮手段
Name ScopeName
James admin
developer
tester
如何绑定以及如何显示所选项目?谢谢你提前 .
1 回答
编辑
使用java脚本直接获取数据