0

Hellos Guys!

Like the title say I'm trying to check some rows during the load of bootgrid but I'm stuck where every row get selected instead of the one that is supposed to be selected.

this is my code so far.

            $("#agents-grid").bootgrid({
            ajax: true,
            post: function () {
                return {
                    filterProducerCode: $("#filter-producer-code").val(),
                    filterProducerName: $("#filter-producer-name").val()
                }
            },
            url: "GridProducersAsCaptured",
            selection: true,
            multiSelect: true,
            rowSelect: true,
            keepSelection: true,
            templates: {
                search: ""
            },
            converters: {
                money: {
                    from: function (value) { return unmoney(value) },
                    to: function (value) { return money(value) }
                }
            },
            formatters: {
                "link": function (column, row) {
                    return "<a href=\"#\">" + column.id + ": " + row.id + "</a>"
                }
            },
            rowCount: [10, 25, 50, -1],
            labels: {
                infos: "<span style='font-weight:bold;'>Showing {{ctx.start}} to {{ctx.end}} of {{ctx.total}} agents.</span>",
                noResults: "No agents found.",
                loading: 'Loading agents...'
            }
        }).on("selected.rs.jquery.bootgrid", function (e) {
            if ($("#agents-grid").bootgrid("getSelectedRows").length > 0)
                $("#selected-agents").text("( " + $("#agents-grid").bootgrid("getSelectedRows").length + " selected )")
            else $("#selected-agents").text("")
        }).on("deselected.rs.jquery.bootgrid", function (e) {
            if ($("#agents-grid").bootgrid("getSelectedRows").length > 0)
                $("#selected-agents").text("( " + $("#agents-grid").bootgrid("getSelectedRows").length + " selected )")
            else $("#selected-agents").text("")
            }).on("loaded.rs.jquery.bootgrid", function (e) {
                var rowIds = [];
                $('#agents-grid > tbody > tr').each(function (i, row) {
                    //var tds = $(row).find("td").eq(3).find(":text").val();
                    var tds = $(row).find("td").eq(2).html();
                    var tds2 = $(row).find("td").eq(1).html();
                    var tds3 = $(row).find("td").eq(3).html();
                    if (tds3 == "true") {                            
                            //$(row).find('input').attr('checked', 'checked')
                            //this.selectedRows.push(tds2);
                            rowIds.push(tds2);

                        }
                })
                $("#agents-grid").bootgrid("select").push(rowIds)
                //$("#agents-grid").bootgrid("select"(rowIds))


            })

I am identifying the selected rows but the moment to send it to "$("#agents-grid").bootgrid("select"(rowIds))" the function receives it empty and before executing the function rowIds is full with the specific rows I'm looking for.

Any help will be appreciated! Thank you!

Raframi
  • 23
  • 5

1 Answers1

0

Found the problem on my code!

The problem was:

$("#agents-grid").bootgrid("select").push(rowIds)

the fix is:

$("#agents-grid").bootgrid("select", rowIds)
Raframi
  • 23
  • 5