diff --git a/dist/jquery.bootgrid.js b/dist/jquery.bootgrid.js index 6d2a001..5b3769d 100644 --- a/dist/jquery.bootgrid.js +++ b/dist/jquery.bootgrid.js @@ -728,12 +728,15 @@ function renderSearchField() var that = this, tpl = this.options.templates, timer = null, // fast keyup detection - currentValue = "", + currentValue = this.searchPhrase, searchFieldSelector = getCssSelector(css.searchField), search = $(tpl.search.resolve(getParams.call(this))), searchField = (search.is(searchFieldSelector)) ? search : search.find(searchFieldSelector); + // populate search field if initial search phrase provided + $(searchField).val(currentValue); + searchField.on("keyup" + namespace, function (e) { e.stopPropagation(); @@ -1000,7 +1003,7 @@ var Grid = function(element, options) this.converter = null; // The converter for the column that is marked as identifier this.rowCount = ($.isArray(rowCount)) ? rowCount[0] : rowCount; this.rows = []; - this.searchPhrase = ""; + this.searchPhrase = this.options.initialSearchPhrase || ""; this.selectedRows = []; this.sortDictionary = {}; this.total = 0; diff --git a/src/internal.js b/src/internal.js index 0cebaf7..98a648e 100644 --- a/src/internal.js +++ b/src/internal.js @@ -718,12 +718,15 @@ function renderSearchField() var that = this, tpl = this.options.templates, timer = null, // fast keyup detection - currentValue = "", + currentValue = this.searchPhrase, searchFieldSelector = getCssSelector(css.searchField), search = $(tpl.search.resolve(getParams.call(this))), searchField = (search.is(searchFieldSelector)) ? search : search.find(searchFieldSelector); + // populate search field if initial search phrase provided + $(searchField).val(currentValue); + searchField.on("keyup" + namespace, function (e) { e.stopPropagation(); diff --git a/src/public.js b/src/public.js index 2d143c4..62bd50a 100644 --- a/src/public.js +++ b/src/public.js @@ -25,7 +25,7 @@ var Grid = function(element, options) this.converter = null; // The converter for the column that is marked as identifier this.rowCount = ($.isArray(rowCount)) ? rowCount[0] : rowCount; this.rows = []; - this.searchPhrase = ""; + this.searchPhrase = this.options.initialSearchPhrase || ""; this.selectedRows = []; this.sortDictionary = {}; this.total = 0;