Вот что мне было поручено сделать с Datatables и флажком. При загрузке скрыть столбец (он настроен на отображение: нет). Когда флажок установлен, покажите его. Это прекрасно работает, но на странице есть дополнительные флажки. Когда любой из них отмечен, происходит дополнительный вызов службы, который перезагружает страницу, но поскольку для столбца установлено значение «display: none», он скрывает столбец и нарушает макет, вот так. Есть идеи? Я схожу с ума, пытаясь понять это!
Сломанный макет
Правильный макет
Мой код указан ниже.
/*Show profile checkbox*/
$adminUserAccountsShowHideProfiles.change(function(e) {
var $profileChildRows = $adminUserAccountsTable.find('tr.childrow');
var $profileColumn = $adminUserAccountsTable.find('.admin-user-accounts-profile-column');
if ( $(this).is(':checked') ) {
$profileChildRows.show();
$profileColumn.show();
} else {
$profileChildRows.hide();
$profileColumn.hide();
}
});
/*this is for the service call that goes out which reloads the page*/
$adminUserAccountsDisabledCheckbox.change(function() {
var $this = $(this);
ax.UserPrefs('adminUserAccountsCheckboxDisabledSelection',$this.is(':checked'));
$adminUserAccountsDeletedCheckbox.prop("disabled", false);
$adminUserAccountsDeletedCheckboxLabel.removeClass("disabled");
if ($(this).is(':not(:checked)')) {
$adminUserAccountsDeletedCheckbox.prop("disabled", true);
$adminUserAccountsDeletedCheckbox.attr("checked", false);
$adminUserAccountsDeletedCheckboxLabel.addClass("disabled");
};
if ($this.hasClass('initted')) {
setTimeout(function() { ax.Routing.Route(); }, 300);
}
});