我一直在做一个项目,我使用 extjs 来显示一些服务计划。我能够在一开始就填充它。然后我想要一个按钮 onclick 将在网格中填充哪些新数据。我能够成功调用树服务中的函数,但未显示数据。我的treegrid按钮代码是:
{
xtype: 'button',
text: 'Search',
listeners: {
click: function () {
// Ext.getCmp('tree').getView().refresh();
Ext.Ajax.request({
method: 'GET',
extend: 'Ext.data.Model',
fields: ['planid', 'id', 'text', 'startdate', 'enddate', 'iconCls', 'expanded', 'leaf'],
params: {
serviceplanid: serviceplanid,
userid: userid,
// startdate: startdate,
// stopdate: stopdate,
initialstate: initialstate,
fonttype: fonttype,
fonttypeex: fonttypeex
},
url : '/BloomMatrix2/TreeService2.svc/getfulldata',
reader: new Ext.ux.aspNetJsonReader({ root: 'children'
}),
success: function (response) {
//console.log(response);
//swapStrore();
}
});
}
}
},
我的服务读取功能:
[WebGet()]
[OperationContract]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string getdata(String serviceplanid,String userid, String initialstate,String fonttype, String fonttypeex)
{
System.Diagnostics.Debug.WriteLine("IN GETDATA"+initialstate);
SqlConnection Conn = new SqlConnection(CommonFunctions.GetConnectionString("YourConnection"));
Conn.Open();
SqlCommand cmd = new SqlCommand("[dbo].[VMResults_GetCategoriesTree]", Conn);
cmd.Parameters.Add("@UserId", SqlDbType.BigInt).Value = 1;
cmd.Parameters.Add("@ServicePlanCurrent", SqlDbType.Char).Value = "N";
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet ds1 = new DataSet();
adapter.Fill(ds1);
String ret=makeJSON(ds1,initialstate,fonttype,fonttypeex);
return ret;
}
[WebGet()]
[OperationContract]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string getfulldata(String serviceplanid, String userid, String initialstate, String fonttype, String fonttypeex)
{
System.Diagnostics.Debug.WriteLine("IN GETDATA" + initialstate);
SqlConnection Conn = new SqlConnection(CommonFunctions.GetConnectionString("YourConnection"));
Conn.Open();
SqlCommand cmd = new SqlCommand("[dbo].[VMResults_GetCategoriesTree]", Conn);
cmd.Parameters.Add("@UserId", SqlDbType.BigInt).Value = 1;
cmd.Parameters.Add("@ServicePlanCurrent", SqlDbType.Char).Value = "Y";
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adapter.Fill(ds);
String ret = makeJSON(ds, initialstate, fonttype, fonttypeex);
return ret;
}
我必须在单击按钮时调用后一个按钮..提前谢谢