jQWidgets Forums

jQuery UI Widgets Forums Grid custom sort does not hold selected record

This topic contains 7 replies, has 2 voices, and was last updated by  krnacm 8 years, 9 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author

  • krnacm
    Participant

    Hi,

    I’m using custom sorting on grid and I noticed that after I select an record and then I sort by some column the selected record is no more selected instead of the row is still selected. Is there any way how to keep selected record nor row after I resorted the grid?

    Thank you.
    Matej


    Christopher
    Participant

    Hi krnacm,

    The “Custom sorting” demo in our website uses a custom sorting function with custom logic that reloads the source of the jqxGrid after it has been sorted. So using that function you can’t accomplish what you want. See our normal “sorting” demo:
    “http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/sorting.htm?light”, it works exactly as you expect.
    In order to make your custom sorting function work like you want , you’ll have to add your own custom function or modify the current one to fit your requirements.

    Best Regards,
    Christopher

    jQWidgets Team
    http://www.jqwidgets.com


    krnacm
    Participant

    Hi Christopher,

    I do understand that in normal sorting it is working how I expect. But I need to have custom sorting with holding selected record.

    Can you advise what do I need to add in the custom sorting function that the selected record will be selected and not the selected row.

    Thank you

    Kind regards,
    Matej


    krnacm
    Participant

    Any suggestion how to handle this request?

    Thank you.


    Christopher
    Participant

    Hi krnacm,

    May I ask, why do you need to use a custom sorting function? Maybe we can do it using the standart sorting function and keep the selection working after the data has been sorted. Please, share your working scenario with us and maybe we can offer you a better solution with minimal customizations on the code.

    Best Regards,
    Christopher

    jQWidgets Team
    http://www.jqwidgets.com


    krnacm
    Participant

    For example I have column with datetime but it is type of string because the date time column contains also time zone information e.g 22.08.2016 UTC. And for correct sorting by datetime I have created custom function for sorting where when sorting is applied on this column the custom sorting function is sorting by an hidden column with just datetime without time zone information. Without this custom sort function the sorting is not correct because it is sorted like a string instead of like a date.

    Any advise how to do it with working selection record after sorting will be much appreciated.

    Thank you.
    Matej


    Christopher
    Participant

    Hi krnacm,

    In this case, there’s no need to use a custom sorting function. It can be done using the normal sorting function of the jqxGrid. All you have to do is set the datafield for the date to be of type “date”, not string, and apply the “cellsformat” property on the column with the dates. That way you will elliminate the timezone info you usually get from the date format.
    Here is a demo:
    http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/sorting.htm?light

    Doing so, the sorting will work flawlessly on dates and it will keep your prevous row selection.

    Best Regards,
    Christopher

    jQWidgets Team
    http://www.jqwidgets.com


    krnacm
    Participant

    Hi Christopher,

    but I need to have the time zone there. Is it possible to have column of type date with time zine presented?

    Thank you.

    Kind regards,
    Matej

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.