Sorting issue !

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gary

    #1

    Sorting issue !

    Hi,

    We are facing a typical problem with sorting a datagrid in Windows
    application ( c# )

    The scenario

    We have a datagrid which is binded to a dataview which conatins two columns
    say Name and Age.

    We tried with allowsorting property, to make the sorting enable and it is
    working fine.

    But the problem is

    As soon as a user enters some value in new row, and leaves the row, the row

    display position will change, based on the sort order. This is very much

    Odd looking. Actually what I expect is, the new row should stay in the last

    poistion, until the user does some action (like clicking the column header)

    to sort it again.

    For acheiving this, we tried with setting the allowsorting property back

    to false as soon as the sorting is finished once then the display will also
    get unsorted, which is not expected.

    It will be of great help if someone can sort out this problem. Thanks in
    advance.

    - Gary -



  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Sorting issue !

    Gary,

    In this case, you are going to have to create an extra column on the
    data source which will determine the sort order. Basically, this column
    will contain a numeric value which you can sort on. Now, to determine what
    the value is, you will have to sort the items in the data view that are not
    changed. Then, you will add the new values that correspond to the new rows
    after that.

    However, every time the sort order is changed, you will have to
    recompute the column's value.

    Personally, I would live with the datagrid, because I consider it
    correct (the user asked for sorted values, that's what the user gets). I
    would just make sure that the new item is selected after it is inserted.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Gary" <msnews@microso ft.com> wrote in message
    news:e3NaYHtkDH A.688@TK2MSFTNG P10.phx.gbl...[color=blue]
    > Hi,
    >
    > We are facing a typical problem with sorting a datagrid in Windows
    > application ( c# )
    >
    > The scenario
    >
    > We have a datagrid which is binded to a dataview which conatins two[/color]
    columns[color=blue]
    > say Name and Age.
    >
    > We tried with allowsorting property, to make the sorting enable and it is
    > working fine.
    >
    > But the problem is
    >
    > As soon as a user enters some value in new row, and leaves the row, the[/color]
    row[color=blue]
    >
    > display position will change, based on the sort order. This is very much
    >
    > Odd looking. Actually what I expect is, the new row should stay in the[/color]
    last[color=blue]
    >
    > poistion, until the user does some action (like clicking the column[/color]
    header)[color=blue]
    >
    > to sort it again.
    >
    > For acheiving this, we tried with setting the allowsorting property back
    >
    > to false as soon as the sorting is finished once then the display will[/color]
    also[color=blue]
    > get unsorted, which is not expected.
    >
    > It will be of great help if someone can sort out this problem. Thanks in
    > advance.
    >
    > - Gary -
    >
    >
    >[/color]


    Comment

    Working...