使用向上和向下按钮进行树视图控制并保存更改 [英] using up and down button for treeview control and save changes

查看:87
本文介绍了使用向上和向下按钮进行树视图控制并保存更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绑定到sql table的树视图.在我的树视图的右侧,我有两个按钮,一个用于将节点向上移动,另一个用于将节点向下移动.我想保存节点的位置.例如,当我向上移动节点时,我希望将其保存在表中,以便下次打开网页时,节点的外观与我关闭页面时的外观相同.我的意思是用户进行更改,应该将其保存.

i have a treeview that is bound to sql table.and in the right hand side of my treeview i have two buttons ,one for move the nodes upper,and the other is to move them down.and it works perfectly.but i want to save the position of the nodes . for example when i move the node up ,i want that to be saved in my table,so that the next time i open the webpage, the appearance of the nodes be the same as when i closed my page.i mean when users make changes,it should be saved .

推荐答案

您实际上并没有提出特定的问题,但是问题是否在于对基础表进行建模:

为了保存节点在数据库中的位置,您可以使用一张表来定义节点关系.一种方法是使用带有自联接的表.例如(伪代码):
You didn''t actually ask a specific question, but if the problem is in modeling the underlying table:

In order to save the position of the nodes in the database you could have a table defining the node relations. One way to do this is to use a table with a self-join. For example (pseudo code):
table MyNodes
   NodeId    --primary key
   Position  --position in the treeview, starting from 0/1 for each parent
   ParentId  --Foreign key to NodeId, null if it is a root node
   ...other columns describing the node, perhaps user etc...


通过使用这种结构,您可以定义树的任何级别的节点顺序.

您最有可能必须手动填充树视图,因为直接绑定可能无法处理数据库结构,但这取决于您使用的机制.


By using this kind of structure you can define the order of nodes at any level of your tree.

Most likely you have to fill the treeview by hand because the direct binding may not be capable of handling the database structure, but that depends on the mechanism you have used.


这篇关于使用向上和向下按钮进行树视图控制并保存更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆