Thread: [pgadmin-hackers] [pgAdmin4][Patch]: RM1938 - Backgrid sorting not working forInteger/Number types

Hi,

As the type of data we get from server side is of string type, due to which the sorting for Integer/Number type columns is not working.

To fix this issue, we are using BigNumber JS library.
We are overriding Backgrid's sort and make_comparator method in backgrid.pgadmin.js.

When sorting is performed based on column we identify the column type(integer/number) and then convert its value into BigInteger and the sorts data.

This patch is dependent on patch sent for "Adding support for BigNumber JS library".

Also, thanks to Murtuza for help.

Please find attached patch and review.


Thanks,
Surinder Kumar
Attachment
Hi Dave,

I just missed the code for swapping left and right values if order is descending. It's fixed.
Please find attached patch and review.

On Mon, Jan 9, 2017 at 9:05 AM, Dave Page <dpage@pgadmin.org> wrote:
Hi

On Friday, January 6, 2017, Surinder Kumar <surinder.kumar@enterprisedb.com> wrote:
Hi,

As the type of data we get from server side is of string type, due to which the sorting for Integer/Number type columns is not working.

To fix this issue, we are using BigNumber JS library.
We are overriding Backgrid's sort and make_comparator method in backgrid.pgadmin.js.

When sorting is performed based on column we identify the column type(integer/number) and then convert its value into BigInteger and the sorts data.

This patch is dependent on patch sent for "Adding support for BigNumber JS library".

Also, thanks to Murtuza for help.

Please find attached patch and review.

This works fine for ascending sorts, but if i click the row header a second time for a descending sort, the order isn't reversed as expected.

Thanks, Dave. 


--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Attachment
Thanks - that works nicely, so patch applied.

On Mon, Jan 9, 2017 at 3:42 PM, Surinder Kumar
<surinder.kumar@enterprisedb.com> wrote:
> Hi Dave,
>
> I just missed the code for swapping left and right values if order is
> descending. It's fixed.
> Please find attached patch and review.
>
> On Mon, Jan 9, 2017 at 9:05 AM, Dave Page <dpage@pgadmin.org> wrote:
>>
>> Hi
>>
>> On Friday, January 6, 2017, Surinder Kumar
>> <surinder.kumar@enterprisedb.com> wrote:
>>>
>>> Hi,
>>>
>>> As the type of data we get from server side is of string type, due to
>>> which the sorting for Integer/Number type columns is not working.
>>>
>>> To fix this issue, we are using BigNumber JS library.
>>> We are overriding Backgrid's sort and make_comparator method in
>>> backgrid.pgadmin.js.
>>>
>>> When sorting is performed based on column we identify the column
>>> type(integer/number) and then convert its value into BigInteger and the
>>> sorts data.
>>>
>>> This patch is dependent on patch sent for "Adding support for BigNumber
>>> JS library".
>>>
>>> Also, thanks to Murtuza for help.
>>>
>>> Please find attached patch and review.
>>
>>
>> This works fine for ascending sorts, but if i click the row header a
>> second time for a descending sort, the order isn't reversed as expected.
>>
>> Thanks, Dave.
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>



--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company