树网格ajax在extjs中不刷新
我一直在做一个项目,我使用extjs来显示一些服务计划。我能够在开始时填充它。然后我想点击一个按钮,在网格中填充新数据。 我能够成功调用树服务中的函数,但数据未显示。 我的treegrid按钮代码是:树网格ajax在extjs中不刷新,ajax,extjs,Ajax,Extjs,我一直在做一个项目,我使用extjs来显示一些服务计划。我能够在开始时填充它。然后我想点击一个按钮,在网格中填充新数据。 我能够成功调用树服务中的函数,但数据未显示。 我的treegrid按钮代码是: { xtype: 'button', text: 'Search', listeners: { click: function () {
{
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;
}
单击按钮后,我必须调用后一个。提前感谢您需要在树上使用与服务器对话的代理来定义存储。参见Sencha示例
或者,如果您想像代码中那样运行自己的AJAX请求,那么您需要从成功块中手动解析的数据中创建对象,并将它们逐个添加到树面板中,这样做并不漂亮。当我尝试使用代理在树上存储定义的上述方法时,什么也没有发生和服务器通话。在这种情况下,我可以调用函数,但当它写入json字符串时,会发生错误。基本上,这里没有读取参数,急需帮助。但是第二种方法太混乱了。我能不能在函数获取json并显示服务计划后刷新网格最好的办法是密切关注示例。如果您遇到错误,请寻求帮助以解决该特定问题。我想我可以获取数据,但树网格没有被刷新。知道我应该把这个加载程序调用放在哪里吗:tree.getLoader().load(tree.getRootNode());谢谢你不断的回复。加载器?你用的是什么版本?