almost same question here,
I want to add pages directly into the database, this works ok except tab order so far, I have created a query which updates the tab order for a given parent. with this query the tab order for all tabs with a specific parent are renumbered from 1 to n.
But I am not sure if this results in a correct behaviour. Is it ok when a tabOrder is not unique for different parents?(see table for example)
Part of the query: results are in the #NewTab table
declare @CurrentID int
declare @ParentID int
drop table #NewTabs
create table #NewTabs(TabID int, ParentID int, OldTabOrder int, NewTabOrder int, [Auto] int identity(1,1), Done bit)
select @CurrentID = (Select top 1 TabID from Tabs where isDeleted = 0 AND ParentID is null and TabID =["specific parent"])
INSERT INTO #NewTabs(TabID,ParentID, OldTabOrder, Done)
SELECT TabID, ParentID, TabOrder, 0
FROM Tabs where parentID = @CurrentID
UPDATE #newTabs set NewTabOrder = [Auto] where OldTaborder < 10000
select * from #NewTabs
tabid |
parentid |
taborder |
1 |
null |
1 |
2 |
1 |
2 |
3 |
1 |
3 |
4 |
null |
4 |
5 |
4 |
1 |
6 |
4 |
2 |
7 |
4 |
3 |