re-ordering rows/records | | |
Any good routines or suggestions to assist me in re-ordering my records in my
datagrid?
i.e. I have a field in each record that is used for ordering (i.e. 1,2,3,4).
I would like to implement a set of options to move the record up one, down
one, move to top, move to bottom of this order. Thus changing that field
values, and the others in the table.
so then I can sort based on that field to order the values.
Using SQl server as backend. Frame 1.1
thanx. | | | | re: re-ordering rows/records
Likely you want to do this on server side. Get buttons click events, get the
grid's selected item and reorganize the datatable. It is easier to update
the table if you make order values in units of thousands, like 1000, 2000,
3000 rather than 1, 2, 3. Then, when you move a record, you just set its
order value between the neighbor record ones and there is no need to change
all other records.
Eliyahu
"Chris" <Chris@discussions.microsoft.com> wrote in message
news:10910ADB-E841-4309-8707-E9D5CF02BE6C@microsoft.com...[color=blue]
> Any good routines or suggestions to assist me in re-ordering my records in[/color]
my[color=blue]
> datagrid?
>
> i.e. I have a field in each record that is used for ordering (i.e.[/color]
1,2,3,4).[color=blue]
> I would like to implement a set of options to move the record up one, down
> one, move to top, move to bottom of this order. Thus changing that field
> values, and the others in the table.
>
> so then I can sort based on that field to order the values.
> Using SQl server as backend. Frame 1.1
>
> thanx.[/color] | | | | re: re-ordering rows/records
thanx!
"Eliyahu Goldin" wrote:
[color=blue]
> Likely you want to do this on server side. Get buttons click events, get the
> grid's selected item and reorganize the datatable. It is easier to update
> the table if you make order values in units of thousands, like 1000, 2000,
> 3000 rather than 1, 2, 3. Then, when you move a record, you just set its
> order value between the neighbor record ones and there is no need to change
> all other records.
>
> Eliyahu
>
> "Chris" <Chris@discussions.microsoft.com> wrote in message
> news:10910ADB-E841-4309-8707-E9D5CF02BE6C@microsoft.com...[color=green]
> > Any good routines or suggestions to assist me in re-ordering my records in[/color]
> my[color=green]
> > datagrid?
> >
> > i.e. I have a field in each record that is used for ordering (i.e.[/color]
> 1,2,3,4).[color=green]
> > I would like to implement a set of options to move the record up one, down
> > one, move to top, move to bottom of this order. Thus changing that field
> > values, and the others in the table.
> >
> > so then I can sort based on that field to order the values.
> > Using SQl server as backend. Frame 1.1
> >
> > thanx.[/color]
>
>
>[/color] | | | | re: re-ordering rows/records
I've set it up this way, any ideas on preventing dup vlaues? My routine has
the added level of complexity of move to top or move to bottom. But I thought
thta if I set the value, for example, +2 for the move item and -2 for the
original item that I'd be safe. I get dup values.
i.e.
1000
2000
3000
4000
5000
move 5000 to top, now item = 998 (-2) and the original item is 1002 (+2).But
sometimes I end up with:
944
946
950
950
how can you move by 1000's? If you set to a value between you would go:
500
1000
2000
3000
and eventually run out of space????????
"Eliyahu Goldin" wrote:
[color=blue]
> Likely you want to do this on server side. Get buttons click events, get the
> grid's selected item and reorganize the datatable. It is easier to update
> the table if you make order values in units of thousands, like 1000, 2000,
> 3000 rather than 1, 2, 3. Then, when you move a record, you just set its
> order value between the neighbor record ones and there is no need to change
> all other records.
>
> Eliyahu
>
> "Chris" <Chris@discussions.microsoft.com> wrote in message
> news:10910ADB-E841-4309-8707-E9D5CF02BE6C@microsoft.com...[color=green]
> > Any good routines or suggestions to assist me in re-ordering my records in[/color]
> my[color=green]
> > datagrid?
> >
> > i.e. I have a field in each record that is used for ordering (i.e.[/color]
> 1,2,3,4).[color=green]
> > I would like to implement a set of options to move the record up one, down
> > one, move to top, move to bottom of this order. Thus changing that field
> > values, and the others in the table.
> >
> > so then I can sort based on that field to order the values.
> > Using SQl server as backend. Frame 1.1
> >
> > thanx.[/color]
>
>
>[/color] | | | | re: re-ordering rows/records
First, like you say at the end, set to a value in between. Also you can
start form 100000, 200000 etc. This will give you more room. Second, when
you find the new number is already taken reset the numbers for all records
to 100000, 200000. You can make a stored procedure to do it on the database
server.
This is just first what comes to my mind. Sure you can find more advanced
algorithms.
Eliyahu
"Chris" <Chris@discussions.microsoft.com> wrote in message
news:59BBDE20-A6DE-41A2-BAAC-550D375235C8@microsoft.com...[color=blue]
> I've set it up this way, any ideas on preventing dup vlaues? My routine[/color]
has[color=blue]
> the added level of complexity of move to top or move to bottom. But I[/color]
thought[color=blue]
> thta if I set the value, for example, +2 for the move item and -2 for the
> original item that I'd be safe. I get dup values.
>
> i.e.
> 1000
> 2000
> 3000
> 4000
> 5000
>
> move 5000 to top, now item = 998 (-2) and the original item is 1002[/color]
(+2).But[color=blue]
> sometimes I end up with:
> 944
> 946
> 950
> 950
>
> how can you move by 1000's? If you set to a value between you would go:
> 500
> 1000
> 2000
> 3000
> and eventually run out of space????????
>
>
> "Eliyahu Goldin" wrote:
>[color=green]
> > Likely you want to do this on server side. Get buttons click events, get[/color][/color]
the[color=blue][color=green]
> > grid's selected item and reorganize the datatable. It is easier to[/color][/color]
update[color=blue][color=green]
> > the table if you make order values in units of thousands, like 1000,[/color][/color]
2000,[color=blue][color=green]
> > 3000 rather than 1, 2, 3. Then, when you move a record, you just set its
> > order value between the neighbor record ones and there is no need to[/color][/color]
change[color=blue][color=green]
> > all other records.
> >
> > Eliyahu
> >
> > "Chris" <Chris@discussions.microsoft.com> wrote in message
> > news:10910ADB-E841-4309-8707-E9D5CF02BE6C@microsoft.com...[color=darkred]
> > > Any good routines or suggestions to assist me in re-ordering my[/color][/color][/color]
records in[color=blue][color=green]
> > my[color=darkred]
> > > datagrid?
> > >
> > > i.e. I have a field in each record that is used for ordering (i.e.[/color]
> > 1,2,3,4).[color=darkred]
> > > I would like to implement a set of options to move the record up one,[/color][/color][/color]
down[color=blue][color=green][color=darkred]
> > > one, move to top, move to bottom of this order. Thus changing that[/color][/color][/color]
field[color=blue][color=green][color=darkred]
> > > values, and the others in the table.
> > >
> > > so then I can sort based on that field to order the values.
> > > Using SQl server as backend. Frame 1.1
> > >
> > > thanx.[/color]
> >
> >
> >[/color][/color] |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,418 network members.
|