Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkbox problem #2279

Open
jnbearon opened this issue Apr 12, 2023 · 2 comments
Open

Checkbox problem #2279

jnbearon opened this issue Apr 12, 2023 · 2 comments

Comments

@jnbearon
Copy link

I have a table with selection check boxes enabled.

My problem is that I do not really want the check boxes to appear on every row. So, dependent on the value in a particular column, I would like the checkbox to be either not present, or disabled.

In practice (because of the nature of the data) this will actually be every alternate row, so a "cheat" could be just to enable on alternate rows rather than by column value.

Is there a way that I can achieve this behaviour?

Thanks

Norman B

@jnbearon
Copy link
Author

I managed to do it by setting checkboxes on the individual fields, rather than the whole table.

@misterparsons
Copy link

You can use the recordsLoaded event, which executes when the DOM for the html table has been constructed so that you can manipulate rows depending on the record data.

Here is a template for you

    recordsLoaded: function(event, data) { // executes when tha table is added to the dom before ndisplaying
	// NOTE. $(this) => "div#PeopleTableContainer(n)
        $(this).find('tbody tr').each(function () {
            record = $(this).data('record');
            if (record.your_field) == your_test ) {
                var td = $(this).find('td.jtable-selecting-column');
                td.attr('title','Selection disabled because your_reason'); // optional to show why disabled
                td.find('input').attr('disabled', true);
            }
        });
        $(this).tooltip();
    }

Just edit your_field, your_test and your_reason to make it suitable for your context.

There is more description in my tutorial

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants