Добавить CheckBox в таблицу из средства форматирования - PullRequest
1 голос
/ 27 мая 2020

Я создаю свою таблицу с этим кодом

    <table class="table table-striped table-bordered dataTable" id="tabela-agencias" style="margin: 30px 0px 65px;">
            <thead>
                <tr>
                    <th data-column-id="aa">@Html.LabelFor(model => model.First().aa)</th>
                    <th data-column-id="Name">@Html.LabelFor(model => model.First().Name)</th>
                    <th data-column-id="Name">@Html.LabelFor(model => model..First().NameLast)</th>
                    <th data-column-id="ccc">@Html.LabelFor(model => model.First().ccc)</th>
                    <th data-column-id="ddd">@Html.LabelFor(model => model.First().ddd).ToString().Replace(",", ".")</th>
                    <th data-column-id="bbb">@Html.LabelFor(model => model.First().bbb).ToString().Replace(",", ".")</th>
                    <th data-column-id="CreatedDate">@Html.LabelFor(model => model.First().CreatedDate)</th>
                    <th data-column-id="Status">@Html.LabelFor(model => model.First().Status)</th>
                    <th data-column-id="CheckBox"></th>
                    <th data-formatter="Details"></th>
                </tr>
            </thead>
            <tbody></tbody>
        </table>

И я не знаю, как добавить флажок в столбце CheckBox, я пробовал вот так:

<script>
var delegate = function (request) { request.Name = $("#Name").val(); return request; };
var formatter = {
    "Details": function (column, row) {
        return '<a href="/xxxxx/ccccc/vvvvvvv/?Id=' + row.Id + ' ">Detalhes</a>';
    },
       "CheckBox": function (column, row) {
           return "<td> "+
               "<input type='checkbox' id='check1' name='a1' value='false'/> " +
               "</td>";
    }
};
_applyPagination(".table", delegate, "/zzzzzz/oooooooo/xxxxxxxResults", formatter, "#btnSearch", "#resetSearch");

, но результатом является столбец с текстом «True». Может кто мне поможет

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...