jQWidgets Forums

jQuery UI Widgets Forums Grid Column header click event not giving correct value

Tagged: 

This topic contains 3 replies, has 2 voices, and was last updated by  Martin 6 years, 8 months ago.

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

  • priyamsharma2704
    Participant

    Hi, I have a jqxGrid in which I customize the column headers by adding an image to it. When I click on the image, a function is called and in that function I am just printing that column’s datafield. But the issue is that I have to click on that particular column header’s image twice to get the correct value. E.g. For the very first time when I click on 2nd column header’s image ,it does not print anything to the console. But when I click on the same column header’s image again, it will print the datafield correctly. Now if I try to click the 3rd column header’s image, it prints the previous column’s datafield. But when I click on 3rd column header’s image again then it gives me the correct value. Is there something that I am missing? I have attached the jseditor link below. Please look into it.

    https://jseditor.io/?key=jqxgrid-header-ver-2

    thanks


    Martin
    Participant

    Hello priyamsharma2704,

    Actually, in the moment you are printing the datafield of the column that is sorted when you click on an image.
    I would suggest you to pass the column’s datafield as an attribute of the element in the headerRenderer method and then take it by event.target.getAttribute('datafield') in addCol(event).

    I have updated your fiddle Example so you can check this.

    Best Regards,
    Martin

    jQWidgets Team
    http://www.jqwidgets.com/


    priyamsharma2704
    Participant

    Hi Martin, I tried your example, but it looks like “columnHeaderElement” returns all column’s text which have “renderer” function. In the fiddle example if I console.log the “columnHeaderElement”, it give me the column’s text and not the datafields. In the fiddle example the datafields and the texts are same for each column. But in my case all columns have same text but different datafields. Is there a way to pass the column’s datafield instead of column text?

    Thanks for the help.


    Martin
    Participant

    Hello priyamsharma2704,

    Then in your case, instead of using the “columnHeaderElement” for displaying the datafield,
    you can use this.datafield inside the headerRenderer, as here “this” is the context of the grid’s current column.
    I’ve updated the Example.

    Best Regards,
    Martin

    jQWidgets Team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.