cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div id="myRepeater" class="repeater" data-staticheight="true">

    <div class="repeater-header">
        <div class="repeater-header-left">
            <div class="repeater-search">
                <div class="search disabled input-group">
                    <input type="search" class="form-control" placeholder="Search" />
                    <span class="input-group-btn">
                        <button class="btn btn-default" type="button">
                            <span class="glyphicon glyphicon-search"></span>
                            <span class="sr-only">Search</span>
                        </button>
                    </span>
                </div>
            </div>
        </div>
        <div class="repeater-header-right">
            <div class="btn-group selectlist disabled repeater-filters">
                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                    <span class="selected-label"></span>
                    <span class="caret"></span>
                    <span class="sr-only">Toggle Filters</span>
                </button>
                <ul class="dropdown-menu pull-right" role="menu">
                    <li data-value="all" data-selected="true" data-property="all"><a href="#">All Items</a></li>
                    <li class="divider"></li>
                    <li data-value="draft" data-property="status"><a href="#">Draft</a></li>
                    <li data-value="archived" data-property="status"><a href="#">Archived</a></li>
                    <li data-value="active" data-property="status"><a href="#">Active</a></li>
                </ul>
                <input class="hidden hidden-field" name="filterSelection" readonly="readonly" aria-hidden="true" type="text" />
            </div>
        </div>
    </div>


    <div class="repeater-viewport">
        <div class="repeater-canvas"></div>
        <div class="loader repeater-loader"></div>
    </div>


    <div class="repeater-footer">
        <div class="repeater-footer-left">
            <div class="repeater-itemization">
                <span>
                    <span class="repeater-start"></span> - <span class="repeater-end"></span> of <span class="repeater-count"></span> items
                </span>
                <div class="btn-group selectlist dropup" data-resize="auto">
                    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                        <span class="selected-label"></span>
                        <span class="caret"></span>
                        <span class="sr-only">Toggle Dropdown</span>
                    </button>
                    <ul class="dropdown-menu" role="menu">
                        <li data-value="10" data-selected="true"><a href="#">10</a></li>
                        <li data-value="25"><a href="#">25</a></li>
                        <li data-value="50"><a href="#">50</a></li>
                    </ul>
                    <input class="hidden hidden-field" name="itemsPerPage" readonly="readonly" aria-hidden="true" type="text" />
                </div>
                <span>Per Page</span>
            </div>
        </div>
        <div class="repeater-footer-right">
            <div class="repeater-pagination">
                <button type="button" class="btn btn-default btn-sm repeater-prev">
                    <span class="glyphicon glyphicon-chevron-left"></span>
                    <span class="sr-only">Previous Page</span>
                </button>
                <label class="page-label" id="myPageLabel">Page</label>
                <div class="repeater-primaryPaging active">
                    <div class="input-group input-append dropdown combobox dropup">
                        <input type="text" class="form-control" aria-labelledby="myPageLabel" />
                        <div class="input-group-btn">
                            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                <span class="caret"></span>
                                <span class="sr-only">Toggle Dropdown</span>
                            </button>
                            <ul class="dropdown-menu dropdown-menu-right"></ul>
                        </div>
                    </div>
                </div>
                <input type="text" class="form-control repeater-secondaryPaging" aria-labelledby="myPageLabel" />
                <span>of <span class="repeater-pages"></span></span>
                <button type="button" class="btn btn-default btn-sm repeater-next">
                    <span class="glyphicon glyphicon-chevron-right"></span>
                    <span class="sr-only">Next Page</span>
                </button>
            </div>
        </div>
    </div>

</div>

            
          
!
            
              #myRepeater {
    position: absolute;
    top: 25px;
    right: 25px;
    bottom: 25px;
    left:25px;
}
            
          
!
            
              // Clear the console on every subsequent run.
// There are many points below where you can
// uncomment a console.log to gain better
// understanding of how this code works.
console.clear();



// Define the data to be displayed in the repeater.
function staticDataSource(options, callback) {

    // Define the columns for the grid
    var columns = [{
        'label': 'Name', // Column header label.
        'property': 'name', // The JSON property you are binding to.
        'sortable': true // Is the column sortable.
    }, {
        'label': 'Description',
        'property': 'description',
        'sortable': true
    }, {
        'label': 'Status',
        'property': 'status',
        'sortable': true
    }, {
        'label': 'Category',
        'property': 'category',
        'sortable': true
    }];

    // Generate the rows in your dataset.
    // NOTE: The property names of your items should
    // match the column properties defined above.
    function generateDummyData() {
        var items = [];
        var amountOfItems = 100; //Change this number
        var statuses = ['Archived', 'Active', 'Draft'];
        var categories = ['New', 'Old', 'Upcoming'];

        function getRandomStatus() {
            var index = Math.floor(Math.random() * statuses.length);
            return statuses[index];
        }

        function getRandomCategory() {
            var index = Math.floor(Math.random() * categories.length);
            return categories[index];
        }

        for (var i = 1; i <= amountOfItems; i++) {
            var item = {
                id: i,
                name: 'Item ' + i,
                description: 'Desc ' + i,
                status: getRandomStatus(),
                category: getRandomCategory()
            }
            items.push(item);
        };

        // Uncomment these to see in your console the
        // JSON payload produced by this function.
        //console.log(JSON.stringify(items));
        //console.table(items);

        return items;
    }

    var items = generateDummyData();

    // These are the visible UI options of the repeater,
    // such as how many items to display per page. They
    // are provided by the Fuel library.
    //console.log(options);

    // Set the values that will be used in your dataSource.
    var pageIndex = options.pageIndex;
    var pageSize = options.pageSize;
    var totalItems = items.length;
    var totalPages = Math.ceil(totalItems / pageSize);
    var startIndex = (pageIndex * pageSize) + 1;
    var endIndex = (startIndex + pageSize) - 1;
    if (endIndex > totalItems) {
        endIndex = totalItems;
    }
    var rows = items.slice(startIndex - 1, endIndex);

    // Define the datasource.
    var dataSource = {
        'page': pageIndex,
        'pages': totalPages,
        'count': totalItems,
        'start': startIndex,
        'end': endIndex,
        'columns': columns,
        'items': rows
    };

    //console.log(dataSource);

    // Pass the datasource back to the repeater.
    callback(dataSource);
}



// Initialize the repeater.
$('#myRepeater').repeater({
    // Setup your custom datasource to handle data retrieval;
    // responsible for any paging, sorting, filtering, searching logic.
    dataSource: staticDataSource,
    // Other options can be placed here as well, such as text to
    // display if no data is returned.
    list_noItemsHTML: "No items found."
    // See: getfuelux.com/javascript.html#repeater-usage-options
    // for more options to put here.
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console