Author Topic: I can't get the RowID of checkboxes I found the source of the problem. Your Id  (Read 311 times)

necatiozbek

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 19
    • View Profile
Your demo link:  https://paramquery.com/pro/demos/checkbox_id

In this example your data is:
var data = [
            { id: 1, company: 'Exxon Mobil', revenues: '339938.0', profits: '36130.0', state: true },
            { id: 2, company: 'Wal-Mart Stores', revenues: '315654.0', profits: '11231.0' },
            { id: 3, company: 'Royal Dutch Shell', revenues: '306731.0', profits: '25311.0' },
            { id: 4, company: 'BP', revenues: '267600.0', profits: '22341.0' },
            { id: 5, company: 'General Motors', revenues: '192604.0', profits: '-10567.0' },

        ]
Change the id field in this example to this idnote,wow in another way

var data = [
            { idnote: 1, company: 'Exxon Mobil', revenues: '339938.0', profits: '36130.0', state: true },
            { idnote: 2, company: 'Wal-Mart Stores', revenues: '315654.0', profits: '11231.0' },
            { idnote: 3, company: 'Royal Dutch Shell', revenues: '306731.0', profits: '25311.0' },
            { idnote: 4, company: 'BP', revenues: '267600.0', profits: '22341.0' },
            { idnote: 5, company: 'General Motors', revenues: '192604.0', profits: '-10567.0' },

        ]
Replace the dataIndx: "id" field in the ColModel field with the field name you just wrote.(idnote)

Then press the Edit and Run button.
Then tick 3-4 Checkboxand press the GetRowId  button.
The result is zero alert


That's why it doesn't work in my project. If I load your data sample it works.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6307
    • View Profile
Thanks for pointing it out, please correct your code ( colModel and event listener ) with the updated example.

https://paramquery.com/pro/demos/checkbox_id

If name of checkbox column is changed, then you also need to update the listener function.

Code: [Select]
listener: function () {
    var checked = this.Checkbox('idnote').getCheckedNodes().map(rd => rd.idnote );
    alert(checked);
}                   

necatiozbek

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 19
    • View Profile
Thank you it works now

Is there a function or method where I can clear the checked checkboxes after any action (after bind etc etc)?

necatiozbek

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 19
    • View Profile
Dear Paramvir,

I've exhausted you, but I need some more help with these Check Id's.
I need two functions that can be triggered from outside

listener: function () {
    var checked = this.Checkbox('idnote').getCheckedNodes().map(rd => rd.idnote );
    alert(checked);

Can we call this function from outside?

Again, as I mentioned in my previous article, is there a function that I can call from outside to clear the checked checkboxes?

Thank you.



paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6307
    • View Profile
1) All the API of grid can be called from outside by replacing "this" by grid, where grid is js instance of grid.

Code: [Select]
var checked = grid.Checkbox('idnote').getCheckedNodes().map(rd => rd.idnote );

2) Checkboxes can be cleared with unCheckAll and unCheckNodes methods of Checkbox object.

https://paramquery.com/pro/api#method-Checkbox

necatiozbek

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 19
    • View Profile
Thank you paramvir,

"All the API of grid can be called from outside by replacing "this" by grid, where grid is js instance of grid."   >>  This information is very valuable to me