获取tree的id,根据id把数据显示到treegrid里,有思路但实现不来,求具体代码 谢谢各位啦数据传递就和三层顺序一致,
1.DAL
public DataTable GetTreeGrid(Hashtable data)
{
string sorttext=string.Empty;
sorttext = "MenuID ASC";
StringBuilder steWhere=new StringBuilder();
if (!string.IsNullOrEmpty(data["ID"].ToString()))//判断指定的字符串是null还是字符串
{
steWhere.Append("and AppID=@ID");//1
}
string sql = @"select MenuID as id,MenuName as text,AppID,ParentID from S_Menu where 1=1" + steWhere.ToString();
SqlParameter[] parameters ={
new SqlParameter("@ID",SqlDbType.Int,4)//里面的参数要和1处保持一致
};
parameters[0].Value = Util.StrToInt(data["ID"].ToString(), 0);
return DbHelperSQL.Query(sql, parameters).Tables[0];
}
2.中转站
public void getTreeGrid()
{
string json = string.Empty;
String submitJSON = RequestHelper.GetString("ID");
Hashtable data = new Hashtable();
if (!string.IsNullOrEmpty(submitJSON))
{
data = JSON.JsonDecode(submitJSON);
DataTable dt = new Learn.BLL.S_Menu().GetTreeGrid(data);
json = JSON.DataTableToJSON(dt);
}
Response.Write(json);
}
3.页面
div:tree
div:treegrid 属性:onNodesSelect="nodeselect"
<script>
......
tree.on("nodeselect", function (e) {
var id = e.node.id;
grid.load({ ID: id });
});