Stacey Fontenot
asked on
Selector Not Working in Bootgrid
I have an MVC C# Web Application and am using jQuery Bootgrid. The bootgrid is populating fine, the issue is there is a toggle button on the upper right of the grid that allows the user to select which columns in the grid are to be present. This feature is turned on with the following code "columnSelection: true". The issue is the button is not allowing the user to select the fields as it should. I have attached screen shots of how the button is supposed to function. When running through google dev, an error is thrown saying that it cannot find popper.js:1 Failed to load resource; however I have a reference to it (See Script Links below). Maybe it is the order of which I am loading. I have no idea at this point. Thanks.
Grid Snippet -------------------------- ---------- ---
<script>
var grid = $("#grid-data").bootgrid({
ajax: false,
caseSensitive: false,
columnSelection: true,
formatters: {
"commands": function (column, row) {
return "<button type=\"button\" class=\"btn btn-xs btn-default command-edit\" data-row-id=\"" + row.product_id + "," + row.client_id + "," + row.product_name + "," + row.description + "," + row.active + "\"><span class=\"fas fa-pencil-alt\"></span></b utton> " +
"<button type=\"button\" class=\"btn btn-xs btn-default command-delete\" data-row-id=\"" + row.product_id + "\"><span class=\"fas fa-trash-alt\"></span></bu tton>";
}
}
}).on("loaded.rs.jquery.bo otgrid", function () {
/* Executes after data is loaded and rendered */
grid.find(".command-edit") .on("click ", function (e) {
$("#EditProduct").modal("s how");
var array = $(this).data("row-id").spl it(',');
$("#edit_Product_ID").val( array[0]);
$("#edit_Client_ID").val(a rray[1]);
$("#edit_Product_Name").va l(array[2] );
$("#edit_Description").val (array[3]) ;
$("#edit_Active").prop("ch ecked", (array[4] === "Yes" ? true : false));
}).end().find(".command-de lete").on( "click", function (e) {
$("#DeleteProduct").modal( "show");
$("#del_Product_ID").val($ (this).dat a("row-id" ));
});
});
$("#grid-data-header").fin d('.action Bar').prep end(
'<button id="btnAddProduct" class="btn btn-primary tx-11 tx-uppercase pd-y-12 pd-x-25 tx-mont tx-medium float-left" type="button" data-toggle="modal" data-target="#AddProduct"> Add Product</button>');
$(document).ready(function () {
$("#Success").modal('@(Suc cess.Equal s("true") ? "show" : "hide")');
$("#Failure").modal('@(Suc cess.Equal s("false") ? "show" : "hide")');
});
</script>
}
<div class="br-section-wrapper" >
<table class="table table-condensed table-hover table-striped" id="grid-data">
<thead>
<tr class="grid-header-nav">
<th data-column-id="client_id" data-visible="false">Clien t ID</th>
<th data-column-id="client_nam e">Client Name</th>
<th data-column-id="product_id " data-visible="false">Produ ct ID</th>
<th data-column-id="product_na me" data-order="desc">Product Name</th>
<th data-column-id="descriptio n">Descrip tion</th>
<th data-column-id="active" data-type="">Active</th>
<th data-column-id="when_updat ed">Update d</th>
<th data-column-id="who_update d">Updated By</th>
<th data-column-id="commands" data-formatter="commands" data-sortable="false">Comm ands</th>
</tr>
</thead>
<tbody>
@{
foreach (Product product in Model.Products)
{
<tr>
<td>@product.Client_ID</td >
<td>@product.Client_Name</ td>
<td>@product.Product_ID</t d>
<td>@product.Product_Name< /td>
<td>@product.Description</ td>
<td>@(product.Active == true ? "Yes" : "No")</td>
<td>@product.Updated.ToLoc alTime().T oString("M /dd/yyyy") </td>
<td>@product.Updated_By_Na me</td>
<td></td>
</tr>
}
}
</tbody>
</table>
</div>
Script Links Snippet -------------------------- ---------- ---
<script src="~/Scripts/lib/jquery/ jquery-3.3 .1.js"></s cript>
<script src="~/Scripts/lib/popper. js/popper. js"></scri pt>
<script src="~/Scripts/lib/bootstr ap/js/boot strap.min. js"></scri pt>
<script src="~/Scripts/lib/perfect -scrollbar /js/perfec t-scrollba r.jquery.j s"></scrip t>
<script src="~/Scripts/lib/moment/ moment.js" ></script>
<script src="~/Scripts/lib/jquery- ui/jquery- ui.js"></s cript>
<script src="~/Scripts/lib/jquery- switchbutt on/jquery. switchButt on.js"></s cript>
<script src="~/Scripts/lib/peity/j query.peit y.js"></sc ript>
<script src="~/Scripts/lib/highlig htjs/highl ight.pack. js"></scri pt>
<script src="~/Scripts/lib/select2 /js/select 2.min.js"> </script>
<script src="~/Scripts/lib/jquery. bootgrid-1 .3.1/jquer y.bootgrid .min.js">< /script>
<script src="~/Scripts/js/bracket. js"></scri pt>
EE-Selector_Icon.PNG
EE-Selector_Icon_Expanded.PNG
EE-Error.PNG
Grid Snippet --------------------------
<script>
var grid = $("#grid-data").bootgrid({
ajax: false,
caseSensitive: false,
columnSelection: true,
formatters: {
"commands": function (column, row) {
return "<button type=\"button\" class=\"btn btn-xs btn-default command-edit\" data-row-id=\"" + row.product_id + "," + row.client_id + "," + row.product_name + "," + row.description + "," + row.active + "\"><span class=\"fas fa-pencil-alt\"></span></b
"<button type=\"button\" class=\"btn btn-xs btn-default command-delete\" data-row-id=\"" + row.product_id + "\"><span class=\"fas fa-trash-alt\"></span></bu
}
}
}).on("loaded.rs.jquery.bo
/* Executes after data is loaded and rendered */
grid.find(".command-edit")
$("#EditProduct").modal("s
var array = $(this).data("row-id").spl
$("#edit_Product_ID").val(
$("#edit_Client_ID").val(a
$("#edit_Product_Name").va
$("#edit_Description").val
$("#edit_Active").prop("ch
}).end().find(".command-de
$("#DeleteProduct").modal(
$("#del_Product_ID").val($
});
});
$("#grid-data-header").fin
'<button id="btnAddProduct" class="btn btn-primary tx-11 tx-uppercase pd-y-12 pd-x-25 tx-mont tx-medium float-left" type="button" data-toggle="modal" data-target="#AddProduct">
$(document).ready(function
$("#Success").modal('@(Suc
$("#Failure").modal('@(Suc
});
</script>
}
<div class="br-section-wrapper"
<table class="table table-condensed table-hover table-striped" id="grid-data">
<thead>
<tr class="grid-header-nav">
<th data-column-id="client_id"
<th data-column-id="client_nam
<th data-column-id="product_id
<th data-column-id="product_na
<th data-column-id="descriptio
<th data-column-id="active" data-type="">Active</th>
<th data-column-id="when_updat
<th data-column-id="who_update
<th data-column-id="commands" data-formatter="commands" data-sortable="false">Comm
</tr>
</thead>
<tbody>
@{
foreach (Product product in Model.Products)
{
<tr>
<td>@product.Client_ID</td
<td>@product.Client_Name</
<td>@product.Product_ID</t
<td>@product.Product_Name<
<td>@product.Description</
<td>@(product.Active == true ? "Yes" : "No")</td>
<td>@product.Updated.ToLoc
<td>@product.Updated_By_Na
<td></td>
</tr>
}
}
</tbody>
</table>
</div>
Script Links Snippet --------------------------
<script src="~/Scripts/lib/jquery/
<script src="~/Scripts/lib/popper.
<script src="~/Scripts/lib/bootstr
<script src="~/Scripts/lib/perfect
<script src="~/Scripts/lib/moment/
<script src="~/Scripts/lib/jquery-
<script src="~/Scripts/lib/jquery-
<script src="~/Scripts/lib/peity/j
<script src="~/Scripts/lib/highlig
<script src="~/Scripts/lib/select2
<script src="~/Scripts/lib/jquery.
<script src="~/Scripts/js/bracket.
EE-Selector_Icon.PNG
EE-Selector_Icon_Expanded.PNG
EE-Error.PNG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok, so I made the change to the folder reference. I'm still getting the same error. I uploaded screen shots of folder structure and Script References. Something is just not right yet.
EE-Popper.PNG
EE-Script-References.PNG
EE-Error.PNG
EE-Popper.PNG
EE-Script-References.PNG
EE-Error.PNG
Ok I see, try the cdnjs version in my second comment instead.
ASKER
Excellent. Thanks.
You're welcome sir, glad I could help.
Open in new window
Make sure the script is inside lib folder and the parent folder is popper.js not popper or something else.
NOTE: it will be better to name it "popper" vs "popper.js" since the folder shouldn't have an extension