Hii我正在使用jstree插件,我想在添加根节点后创建一个根节点的子节点而不刷新页面,但是我无法做到这一点。请帮助我...
$('button.create').click(function () {
var parentid = null;
var ref = $('#jstree').jstree(true),
sel = ref.get_selected();
if (sel.length) {
sel = sel[0];
console.log(sel)
parentid = sel;
}
$("#jstree").jstree("create_node", parentid, null, "last", function (node) {
this.edit(node);
//$("#jstree").jstree("destroy");
});
});
我的控制器代码是
public void AddEdit(ProductTypeMaster obj)
{
ProductTypesBO model = new ProductTypesBO();
using (NilePlayEntities db = new NilePlayEntities())
{
if (obj.ID > 0)
{
var old = db.ProductTypeMaster.Find(obj.ID);
old.ParentID = old.ParentID;
old.ProductType = obj.ProductType;
old.Position = obj.Position;
old.MenuLevel = obj.MenuLevel;
old.IsActive = old.IsActive;
old.CreatedAt = old.CreatedAt;
db.Entry(old).State = System.Data.Entity.EntityState.Modified;
db.SaveChanges();
}
else
{
obj.CreatedAt = DateTime.Now;
obj.IsActive = true;
obj.MenuLevel = 1;
if (obj.ParentID == null)
{
obj.Position = 0;
}
db.ProductTypeMaster.Add(obj);
db.SaveChanges();
}
}
}
我想在添加根节点后不刷新页面的情况下添加子节点,但是只要我试图将子节点添加到新的根节点中,我就可以做到这一点,它将子节点添加为根节点