ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Grid missing data-k in html table row
Title:
B
I
{code}
?
...Continuing my journey to my task on the Grid with checkboxes. I tried to implement the "get selection" button to show in a div span area just like the demo did. The checkboxes works fine on display but no luck to get the selection going with empty getting the selected value on click for the javascript to run. After a through checking I found that there's an attribute "data-k" missing on each tr datarow, below is an extract of the the row: My grid's TR: `<tr data-lvl="1" data-g="GridChkPersistent" data-i="1" class="awe-row awe-alt awe-selectable">` Demo's TR: `<tr data-k="1999" data-lvl="1" data-g="GridChkPersistent" data-i="1" class="awe-row awe-alt">` I tried to trouleshoot its event on its change event by adding an alert as below: grid.on('change', chkSel, function () { var chk = $(this); var isChecked = chk.val() === 'true'; var key = chk.closest(rowsel).data('k'); if (isChecked) { alert(chk.closest(rowsel).data('k')); vals[key] = 1; } else delete vals[key]; }); The demo can prompt its id as it should and mine is undefined. So my question is how can I get grid to generate that data-k for the grid?
Save Changes
Cancel
Roger Seto
asked at 22 Feb 2022
you need to set the `Key` in the `GridModelBuilder`, as you can see in our demos: `KeyProp = o => o.Id` or `Key = "Id"` an example here also: https://www.aspnetawesome.com/learn/mvc/Grid#Data-binding
at 22 Feb 2022
Omu
Answers
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK