Stacey Fontenot
asked on
Icons Missing in jQuery Bootgrid
I have an MVC C# Web Application and am using jQuery Bootgrid. The bootgrid is populating fine, the issue is I can't seem to get the icons in front of the top right drop downs. See screen shots attached. I am using bootstrap 4. I believe the jquery bootgrid is having a conflict with the fontawesome, but I can't seem to resolve. I have attached screenshots of what I need and what I have.
chtml 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.audience_id + "," + row.client_id + "," + row.audience_name + "," + 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.audience_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) {
$("#EditAudience").modal(" show");
var array = $(this).data("row-id").spl it(',');
$("#edit_Audience_ID").val (array[0])
$("#edit_Client_ID").val(a rray[1]);
$("#edit_Audience_Name").v al(array[2 ]);
$("#edit_Active").prop("ch ecked", (array[3] === "Yes" ? true : false));
}).end().find(".command-de lete").on( "click", function (e) {
$("#DeleteAudience").modal ("show");
$("#del_Audience_ID").val( $(this).da ta("row-id "));
});
});
$("#grid-data-header").fin d('.action Bar').prep end(
'<button id="btnAddAudience" 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="#AddAudience" >Add Audience</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="audience_i d" data-visible="false">Audie nce ID</th>
<th data-column-id="audience_n ame" data-order="desc">Audience Name</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 (Audience audience in Model.Audiences)
{
<tr>
<td>@audience.Client_ID</t d>
<td>@audience.Client_Name< /td>
<td>@audience.Audience_ID< /td>
<td>@audience.Audience_Nam e</td>
<td>@(audience.Active == true ? "Yes" : "No")</td>
<td>@audience.Updated.ToLo calTime(). ToString(" M/dd/yyyy" )</td>
<td>@audience.Updated_By_N ame</td>
<td></td>
</tr>
}
}
</tbody>
</table>
</div>
Script snippet -------------------------- ---------- ---------- ---------- ---
<script src="~/Scripts/lib/jquery/ jquery-3.3 .1.js"></s cript>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<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>
EX-IconsNeeded.PNG
EX-IconsMissing.PNG
chtml 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.audience_id + "," + row.client_id + "," + row.audience_name + "," + 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.audience_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")
$("#EditAudience").modal("
var array = $(this).data("row-id").spl
$("#edit_Audience_ID").val
$("#edit_Client_ID").val(a
$("#edit_Audience_Name").v
$("#edit_Active").prop("ch
}).end().find(".command-de
$("#DeleteAudience").modal
$("#del_Audience_ID").val(
});
});
$("#grid-data-header").fin
'<button id="btnAddAudience" 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="#AddAudience"
$(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="audience_i
<th data-column-id="audience_n
<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 (Audience audience in Model.Audiences)
{
<tr>
<td>@audience.Client_ID</t
<td>@audience.Client_Name<
<td>@audience.Audience_ID<
<td>@audience.Audience_Nam
<td>@(audience.Active == true ? "Yes" : "No")</td>
<td>@audience.Updated.ToLo
<td>@audience.Updated_By_N
<td></td>
</tr>
}
}
</tbody>
</table>
</div>
Script snippet --------------------------
<script src="~/Scripts/lib/jquery/
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<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.
EX-IconsNeeded.PNG
EX-IconsMissing.PNG
ASKER
I'm using bootstrap 4 which is where the problem is. The glyphs are not available in bs 4.
Do you still have the same problem Stacey ?
ASKER
Yes. I have tried everything in the link but nothing works. I have the same problem as described. I have attached a copy of the css file they are referring to. I know it is a linking issue but I have spent many hours with no solution.
jquery.bootgrid.fa.js
jquery.bootgrid.fa.min.js
jquery.bootgrid.fa.js
jquery.bootgrid.fa.min.js
Try to include the font-awesome library in your head section :
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
ASKER
I've included the font-awesome in the head. I believe the issue is still in the jquery.bootgrid.fa.min.js -- referring to the glyph icons.
The content should refer to font-awesome like :
!function(a,b,c){"use strict";a.extend(a.fn.bootgrid.Constructor.defaults.css,{icon:"icon fa",iconColumns:"fa-th-list",iconDown:"fa-sort-desc",iconRefresh:"fa-refresh",iconSearch:"fa-search",iconUp:"fa-sort-asc"})}(jQuery,window);
ASKER
that still didn't resolve.
Could you please share with me the current code you've and a screenshot of the interface, check also if there are any error messages in the browser console.
Hi,
you can try this, this is converting/extending glyphicon to fontawesome v4
https://gist.github.com/blowsie/15f8fe303383e361958bd53ecb7294f9
or another way
Take the glyphicons.less file from Bootstrap 3 GitHub. https://github.com/twbs/bootstrap/blob/master/less/glyphicons.less
It needs these variables:
@icon-font-path: "../fonts/";
@icon-font-name: "glyphicons-halflings-regu lar";
@icon-font-svg-id: "glyphicons_halflingsregul ar";
Then you can convert .less file to a .css file if you prefer
using online tool less2css.org
save it as glyphicons.css and include it in your HTML files
<link href="/Content/glyphicons. css" rel="stylesheet" />
You also need the Glyphicon fonts which is in the Bootstrap 3 package, place this in a /fonts/ directory.
Now, you can use Glyphicons with Bootstrap 4
you can try this, this is converting/extending glyphicon to fontawesome v4
https://gist.github.com/blowsie/15f8fe303383e361958bd53ecb7294f9
or another way
Take the glyphicons.less file from Bootstrap 3 GitHub. https://github.com/twbs/bootstrap/blob/master/less/glyphicons.less
It needs these variables:
@icon-font-path: "../fonts/";
@icon-font-name: "glyphicons-halflings-regu
@icon-font-svg-id: "glyphicons_halflingsregul
Then you can convert .less file to a .css file if you prefer
using online tool less2css.org
save it as glyphicons.css and include it in your HTML files
<link href="/Content/glyphicons.
You also need the Glyphicon fonts which is in the Bootstrap 3 package, place this in a /fonts/ directory.
Now, you can use Glyphicons with Bootstrap 4
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
https://github.com/rstaib/jquery-bootgrid/issues/249