$(function () { var returnsValue; // Type: any returnsValue = $(".selector").wijgrid("columns"); });
function columns() : any;
$(function () { var returnsValue; // Type: any returnsValue = $(".selector").wijgrid("columns"); });
function columns() : any;
var colWidgets = $("#element").wijgrid("columns");
Columns in wijgrid are represented as widgets. This method returns a one-dimensional array of widgets that are bound to visible column headers. The column widget is initiated with values taken from the corresponding item in the wijgrid.options.columns array.
However, the options of a column widget instance do not refer to the original object but instead to a copy created by the widget factory. For this reason, changes to the wijgrid.options.columns option are not automatically propagated to the column widget options and vice versa.
To resolve this issue, wijgrid synchronizes the column widget option values with the source items. This synchronization occurs inside the ensureControl() method which is automatically called each time an action requires wijgrid to re-draw.
Still, there is a drawback. For example, you may want to filter wijgrid data from user code as in this incorrect sample:
$("#element").wijgrid("option", "columns")[0].filterValue = "newValue"; $("#element").wijgrid("ensureControl", true); // Make wijgrid re-shape data and re-render.
In the sample above, nothing happens, because during synchronization, user changes are ignored. You need to change the filterValue of the column widget. This is what the columns() method is for:
$("#element").wijgrid("columns")[0].options.filterValue = "newValue"; $("#element").wijgrid("ensureControl", true); // Make wijgrid re-shape data and re-render.
Here is the best way to change the filterValue:
$("#element").wijgrid("columns")[0].option("filterValue", "newValue"); // The column widget handles everything you need.