Link to home
Start Free TrialLog in
Avatar of Stacey Fontenot
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></button> " +
                    "<button type=\"button\" class=\"btn btn-xs btn-default command-delete\" data-row-id=\"" + row.audience_id + "\"><span class=\"fas fa-trash-alt\"></span></button>";
            },
        }
    }).on("loaded.rs.jquery.bootgrid", 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").split(',');
            $("#edit_Audience_ID").val(array[0])
            $("#edit_Client_ID").val(array[1]);
            $("#edit_Audience_Name").val(array[2]);
            $("#edit_Active").prop("checked", (array[3] === "Yes" ? true : false));

        }).end().find(".command-delete").on("click", function (e) {
            $("#DeleteAudience").modal("show");
            $("#del_Audience_ID").val($(this).data("row-id"));
        });
            });
        $("#grid-data-header").find('.actionBar').prepend(
            '<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('@(Success.Equals("true") ? "show" : "hide")');
            $("#Failure").modal('@(Success.Equals("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">Client ID</th>
                <th data-column-id="client_name">Client Name</th>
                <th data-column-id="audience_id" data-visible="false">Audience ID</th>
                <th data-column-id="audience_name" data-order="desc">Audience Name</th>
                <th data-column-id="active" data-type="">Active</th>
                <th data-column-id="when_updated">Updated</th>
                <th data-column-id="who_updated">Updated By</th>
                <th data-column-id="commands" data-formatter="commands" data-sortable="false">Commands</th>
            </tr>
        </thead>
        <tbody>
            @{
                foreach (Audience audience in Model.Audiences)
                {
                    <tr>
                        <td>@audience.Client_ID</td>
                        <td>@audience.Client_Name</td>
                        <td>@audience.Audience_ID</td>
                        <td>@audience.Audience_Name</td>
                        <td>@(audience.Active == true ? "Yes" : "No")</td>
                        <td>@audience.Updated.ToLocalTime().ToString("M/dd/yyyy")</td>
                        <td>@audience.Updated_By_Name</td>
                        <td></td>
                    </tr>
                }
            }
        </tbody>
    </table>
</div>

Script snippet -----------------------------------------------------------
    <script src="~/Scripts/lib/jquery/jquery-3.3.1.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
    <script src="~/Scripts/lib/bootstrap/js/bootstrap.min.js"></script>
    <script src="~/Scripts/lib/perfect-scrollbar/js/perfect-scrollbar.jquery.js"></script>
    <script src="~/Scripts/lib/moment/moment.js"></script>
    <script src="~/Scripts/lib/jquery-ui/jquery-ui.js"></script>
    <script src="~/Scripts/lib/jquery-switchbutton/jquery.switchButton.js"></script>
    <script src="~/Scripts/lib/peity/jquery.peity.js"></script>
    <script src="~/Scripts/lib/highlightjs/highlight.pack.js"></script>
    <script src="~/Scripts/lib/select2/js/select2.min.js"></script>
    <script src="~/Scripts/lib/jquery.bootgrid-1.3.1/jquery.bootgrid.min.js"></script>
    <script src="~/Scripts/js/bracket.js"></script>
EX-IconsNeeded.PNG
EX-IconsMissing.PNG
Avatar of Zakaria Acharki
Zakaria Acharki
Flag of Morocco image

Hi, take a look at this open issue :

https://github.com/rstaib/jquery-bootgrid/issues/249
Avatar of Stacey Fontenot
Stacey Fontenot

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 ?
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
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" />

Open in new window

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);

Open in new window

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-regular";
@icon-font-svg-id:        "glyphicons_halflingsregular";

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
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members 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.