Hey @JorgenF sorry for the late reply… I seem to have added spaces by mistake in the class identifiers by mistake. I’ve edited and fixed it now… Can you try again?
This is famous code (thanks to @Nic). I see it everywhere
To make it even more robust:
Tables in “Search” views should be supported (currently they aren’t)
Certain rows should be skipped. For example, we probably don’t want checkboxes on a “group” row or “totals” rows.
Given the above, the updated function looks like this:
/*
Example Usage
Add checkboxes...
To a table: addCheckboxes(view)
To a table inside a Search View: addCheckboxes(view, 'search')
To all rows in a Search View: addCheckboxes(view, 'search', true)
To all rows in a Table View: addCheckboxes(view, 'table', true)
*/
function addCheckboxes(view, viewType='table', allRows=false) {
// Tables and search tables have slightly different css
let css
if (viewType == 'search') {
css = '.kn-search'
} else if (viewType == 'table') {
css = '.kn-table'
}
// Decide if we are including all rows (unlikely) or only record rows
const trCSS = allRows ? 'tr' : 'tr[id]'
// Add the checkbox to the header to select/unselect all
$('#' + view.key + css + ' thead tr').prepend('<th><input type="checkbox"></th>')
$('#' + view.key + css + ' thead input').change(function () {
$('.' + view.key + css + ' tbody tr input').each(function () {
$(this).attr('checked', $('#' + view.key + css + ' thead input').attr('checked') != undefined)
})
})
// Add a checkbox to each row in the table body
$('#' + view.key + css + ' tbody ' + trCSS).each(function () {
$(this).prepend('<td><input type="checkbox"></td>')
})
}
Of course, the rest of the code is the same (i.e. call the function inside the view-render event and update your records).
Loving the community involvement on this snippet. Thanks everyone.
This snippet is very helpful, my one issue I am having is increasing the colspan or adding another cell to the total rows since the checkbox column shifts them so they don’t line up.
The total rows behave unpredictably when trying to select them via JS
This snippet works for getting the columns and increasing the colspan of the group headers (added to the same AddCheckboxes function)
All what you’re describing is very intriguing. I’d really like to get access to at least two apps that behave differently to compare them.
Can you create an account for me in each of them, please? Use this email nd@ctrnd.com
Send me the PW in a private message.
No need to see any relevant data, just dummy pages and fake data is ok for testing. I usually create them in a menu called Debug and Test for developers or temporary users only.
No, the legacy style is not important. Bulk Ops should work in a cases.
All apps bulk delete feature work
Good to know - thanks.
No slugs such as _ts work on any app.
I fixed the _ts keyword. Indeed there was a bug that prevented showing the TS when there was no title.
The app name and version of KTL only shows on one app.
This one you shared me shows it as expected. Can you share me another one that doesn’t?
Auto Refresh box with option to pause shows on one app but not the others and does not actually refresh
This checkbox is only shown to users having the Developer role. It is intended to pause the auto refresh keyword (_ar), while you inspect the data - to give you a break! It doesn’t actually refresh the page or anything. Just pause _ar.
BTW, if you want to refresh a specific view, you can do a click, followed by a long press(0.5 sec) on that view, just about anywhere on it.
This shared app is now on a special “dev” version of the KTL (see in the Javascript pane). It’s like a beta for you to test the fixes I’m doing.
Keep testing and let me know what you find. I’ll fix it.
I’m constantly facing requirements to select multiple rows in a table that have a Yes / No column and would like the ability to change all selected from No to Yes or even if the field is blank to Bulk either Yes / NO
Yes, you can do Bulk Edits on Yes/No fields.
You can also use the cool _qt k(Quick Toggle) keyword in your grid.
Add this to your description (or title)
_qt=palegreen, transparent
To get green background color on Yes and no color on No
or
_qt=palegreen, #f55
To get green background color on Yes and pale red color on No
You can click all cells in a quick sequence, without having to wait for each transition to complete. They are queued in memory and executed automatically.