RadiantQ jQuery Gantt Package
Bootstrap
Previous Topic  Next Topic 

In this topic we discuss how to use the RadiantQ jQuery Gantt along with Bootstrap, in the process addressing any issues that need to be addressed.


Note: A working sample of this topic can be found in the ..\PatternSamples\Bootstrap folder.


Including Bootstrap Files

a) Bootstrap js files


Include the Bootstrap JS files in a folder like this from our sample: "..\PatternSamples\Bootstrap\js".


b) Bootstrap css files


Include the Bootstrap CSS files in a folder like this from our sample: "..\PatternSamples\Bootstrap\css".


c) Fonts


Bootstrap uses some fonts and icon files that are used in it's Navbar and other controls. Include this Bootstrap folder in a path like this: "..\PatternSamples\Bootstrap\fonts"


Including Gantt References


a) HTML file referencing the Gantt Widget


First copy over all required Gantt files into the project folder. Please reference the above PatternSamples sample for the full set of files to include. This is also discussed in detail in the GanttControl Getting Started and FlexyGantt Getting Started topic.


Create a new HTML file inside the project directory (GanttWithBootstrap.html) and reference the following source files and the corresponding Bootstrap related js files and css files.


<head>

    <title></title>

    <link href="Src/Styles/jQuery-ui-themes/smootness/jquery-ui.css" rel="stylesheet" />

    <link href="Src/Styles/radiantq.gantt.default.css" rel="stylesheet" />

    <link href="css/bootstrap.min.css" rel="stylesheet"/>

    <link href="css/jquery.bootstrap-touchspin.css" rel="stylesheet"/>

    <link href="css/bootstrap-datetimepicker.css" rel="stylesheet"/>

    <link href="css/GanttWithBootstrap.css" rel="stylesheet"/>

   <script src="Src/Scripts/jquery-1.11.2.min.js" type="text/javascript"></script>

    <script src="Src/Scripts/jquery-ui-1.11.4/jquery-ui.min.js" type="text/javascript"></script>

    <script type="text/javascript" src="Src/Scripts/jquery.layout-latest.min.js"></script>

    <script src="Src/Scripts/Utils/date.js" type="text/javascript"></script>

    <script src="Src/ResourceStrings/en-US.js" type="text/javascript"></script>

    <script src='Src/Scripts/VW.Grid.1.min.js' type='text/javascript'></script>

    <script src='Src/Scripts/RadiantQ-jQuery.Gantt.5.0.min.js' type='text/javascript'></script>

    <script src="js/bootstrap.min.js"></script>

    <script src="js/bootstrap-contextmenu.js"></script>

    <script src="js/jquery.bootstrap-touchspin.js"></script>

    <script src="js/moment.js"></script>

    <script src="js/bootstrap-datetimepicker.js"></script>

</head>


b) Sample JSON Data


Create a GanttWithBootstrap.json file containing a list of sample tasks to be displayed in the gantt.


Addressing conflicts between Bootstrap and jQuery UI

The Gantt widgets use jQuery UI and Bootstrap has some conflicts with certain jQuery UI plugins. We will address those here.


a) Tooltip styling conflicts.


To avoid some naming conflict between the jQuery UI Tooltip and Bootstrap tooltip, incldue this script:


    <script>

        /*** Handle jQuery plugin naming conflict between jQuery UI and Bootstrap ***/

        var bootstrapTooltip = $.fn.tooltip.noConflict();

        $.fn.bstooltip = bootstrapTooltip;

    </script>



b) Sizing issue in Bootstrap css


Bootstrap.min.css redefines box-sizing to an undesirable setting and has to be reset for the dom elements within the gantt. We do so by including the following css:


  #gantt_container *{

            -webkit-box-sizing: content-box !important;

            -moz-box-sizing: content-box !important;

            box-sizing: content-box !important;

           

} 


The above code will be inside "..\PatternSamples\Bootstrap\css\GanttWithBootstrap.css", "GanttWithBootstrap.css" contains all sample level css styles definitions. 


Including Bootstrap Features within the Gantt


a) Using bootstrap-contextmenu.js instead of Gantt's jQuery UI based built-in context menu. 


The RadiantQ jQuery Gantt provides an easy way to plugin other context menu frameworks, thereby letting the gantt use them instead of it's built-in context menu framework. Below code plugs in the Bootstrap ContextMenu into the RadiantQ Gantt.


 

        RadiantQ.Gantt.ContextMenuImpl.ContextMenu = function (className, scope) {

            var self = this;

            this.ItemClicked = new ObjectEvent("ItemClicked");

            this.BeforeContextMenu = new ObjectEvent("BeforeContextMenu");

            this.selector = className;

            var contextMenu = this;

            this._position = { x: 0, y: 0 };

            this.Items = new RadiantQ.Gantt.Dictionary();


            $(scope).contextmenu({

                target: '#context-menu',

                before: function (e, context) {

                    $("#context-menu ul").empty();

                    if (contextMenu.Items.length != 0) {

                        self.BeforeContextMenu.raise(context, e);

                        // execute code before context menu if shown

                        var menuItems = contextMenu.Items.asArray;

                        for (var i = 0; i < menuItems.length; i++) {

                            var name = menuItems[i].name;

                            var $li = $("<li keyName=" + menuItems[i].keyName + " ><a tabindex='-1' href='#' style='padding:3px 10px'>" + name + "</a></li>");

                            if (menuItems[i].disabled == true)

                                $li.addClass("disabled");

                            $("#context-menu ul").append($li);

                        }

                        return true;

                    } else {


                    }

                },

                scopes: className,

                onItem: function (context, e) {

                    // execute on menu item selection

                    var key = $(e.currentTarget).attr("keyName");

                    self.ItemClicked.raise(key, context);

                }

            });


            this.AddNewItems = function (menuItems, enableDefaultItems) {

                if (enableDefaultItems == false) {

                    this.Items = new RadiantQ.Gantt.Dictionary();

                    for (var i = 0; i < menuItems.length; i++)

                        this.Items.Add(menuItems[i].keyName, menuItems[i]);

                }

                else {

                    for (var i = 0; i < menuItems.length; i++)

                        this.Items.Add(menuItems[i].keyName, menuItems[i]);

                }

            }

            return this;

        }




   <div id="context-menu">

        <ul class="dropdown-menu custom-dropdown-menu" role="menu">

        </ul>

  </div>





b) Bootstrap datetime picker and spinner


We now use a 3rd party bootstrap datetime picker and spinner for editing the table StartTime, EndTime and Progress columns in the Gantt table. 


Note that we have also included the appropriate JS and CSS files required for these plugins in our sample.


c) Bootstrap navigation bar html with buttons to interact with Gantt


        <!-- /.navbar-start -->

    <div style="height:45px">

         <nav class="navbar navbar-default navbar-fixed-top" role="navigation" style="min-height:40px; height:40px">

        <div class="container" style="width:auto">

            <!-- Brand and toggle get grouped for better mobile display -->

            <div class="navbar-header">

                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">

                    <span class="sr-only">Toggle navigation</span>

                    <span class="icon-bar"></span>

                    <span class="icon-bar"></span>

                    <span class="icon-bar"></span>

                </button>

            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->

            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">

                <ul class="nav navbar-nav">

                    <li title="Add" id="addRow">

                        <a href="#" class="btn btn-default btn-custom-default btn-sm"><span class="glyphicon custom-glyphicon glyphicon-plus"></span></a>

                    </li>


                    <li id="InsertNewItemAsSiblingBelow" title="Insert NewItem As SiblingBelow">

                        <a href="#" class="btn btn-default btn-custom-default btn-sm"><span class="glyphicon custom-glyphicon glyphicon-th"></span></a>

                    </li>

                    <li id="InsertNewItemAsChildOf" title="Insert NewItem As ChildOf">

                        <a href="#" class="btn btn-default btn-custom-default btn-sm"><span class="glyphicon custom-glyphicon glyphicon-th-list"></span></a>

                    </li>


                    <li title="delete" id="remove">

                        <a href="#" class="btn btn-default btn-custom-default btn-sm"><span class="glyphicon custom-glyphicon glyphicon-remove"></span></a>

                    </li>

                    <li title="Move up" id="moveup">

                        <a href="#" class="btn btn-default btn-custom-default btn-sm"><span class="glyphicon custom-glyphicon glyphicon-open"></span></a>

                    </li>

                         <li title="Move down" id="movedown">

                        <a href="#" class="btn btn-default btn-custom-default btn-sm"><span class="glyphicon custom-glyphicon glyphicon-save"></span></a>

                    </li>

                    <li title="Indent" id="indent">

                        <a href="#" class="btn btn-default btn-custom-default btn-sm"><span class="glyphicon  custom-glyphicon glyphicon-arrow-right"></span></a>

                    </li>

                    <li title="Outdent" id="outdent">

                        <a href="#" class="btn btn-default btn-custom-default btn-sm"><span class="glyphicon custom-glyphicon glyphicon-arrow-left"></span></a>

                    </li>

                </ul>

            </div>

            <!-- /.navbar-collapse -->

        </div>

        <!-- /.container -->

    </nav>

  </div>

    <!-- /.navbar-End -->





� RadiantQ 2022. All Rights Reserved.