Bootstrap Table - getFieldIndex !string fix

fix #2014 - toggleColumn (due to getFieldIndex) fails unless column.field is string, and likely any other getFieldIndex calls too. Force it to be stored as string around line 618 (`initTable`) OR fix when this is compared, which appears to only be line 49 (`getFieldIndex`). But since a wider search for ".field" showed the second approach might not cover all 'other' quirks if js doesnt natively store this as string, so went with forcing it in `initTable`

by Menuka Ishan

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.10.1/bootstrap-table.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

<button>
test
</button>

<table id="table"
 	data-search="true"
 	data-show-columns="true"
 	data-show-export="true"
 	data-show-refresh="true"
 	data-show-toggle="true"
 	data-sortable="true"
 	data-toolbar="#preamble">

    <thead>
    <tr>
        <th data-field="1" data-sortable="true">First</th>
        <th data-field="second" data-sortable="true">Second</th>
        <th data-field="third" data-sortable="true">Third</th> 
        <th data-field="04" data-sortable="true">Fourth</th>
    </tr>
    </thead>
    </table>

JavaScript

// Bootstrap Table - fix #2014 - toggleColumn (due to getFieldIndex) fails unless column.field is string, and likely any other getFieldIndex calls too.
// Force it to be stored as string around line 618 (`initTable`) 
// OR fix when this is compared, which appears to only be line 49 (`getFieldIndex`). 
// But since a wider search for ".field" showed the second approach might not cover all 'other' quirks if js doesnt natively store this as string, so went with forcing it in `initTable`

 

// see line 615 (`initTable`)

$(document).ready(function(){
  $('#table').bootstrapTable();

  $('#table').bootstrapTable('hideColumn', 'second');
});


/**
 * @author zhixin wen <[email protected]>
 * version: 1.10.1
 * https://github.com/wenzhixin/bootstrap-table/
 */

!function ($) {
    'use strict';

    // TOOLS DEFINITION
    // ======================

    var cachedWidth = null;

    // it only does '%s', and return '' when arguments are undefined
    var sprintf = function (str) {
        var args = arguments,
            flag = true,
            i = 1;

        str = str.replace(/%s/g, function () {
            var arg = args[i++];

            if (typeof arg === 'undefined') {
                flag = false;
                return '';
            }
            return arg;
        });
        return flag ? str : '';
    };

    var getPropertyFromOther = function (list, from, to, value) {
        var result = '';
        $.each(list, function (i, item) {
            if (item[from] === value) {
                result = item[to];
                return false;
            }
            return true;
        });
        return result;
    };

    var getFieldIndex = function (columns, field) {
        var index = -1;

        $.each(columns, function (i, column) {
            if (column.field === field) {
                index = i;
                return false;
            }
            return true;
        });
        return index;
    };

    //...