diff --git a/GridMvc.Site/Scripts/gridmvc.js b/GridMvc.Site/Scripts/gridmvc.js index b6ca50b..6afba21 100644 --- a/GridMvc.Site/Scripts/gridmvc.js +++ b/GridMvc.Site/Scripts/gridmvc.js @@ -171,11 +171,12 @@ GridMvc = (function ($) { //determine widget container: var widgetContainer = $(this).find(".grid-popup-widget"); //onRender target widget - if (typeof (widget.onRender) != 'undefined') + if (typeof (widget.onRender) != 'undefined') { widget.onRender(widgetContainer, self.lang, columnType, filterDataObj, function (values) { self.closeOpenedPopups(); self.applyFilterValues(filterUrl, columnName, values, false); }, $.parseJSON(widgetData)); + } //adding 'clear filter' button if needed: if ($(this).find(".grid-filter-btn").hasClass("filtered") && widget.showClearFilterButton()) { var inner = $(this).find(".grid-popup-additional"); @@ -388,13 +389,16 @@ GridMvc.lang.en = { applyFilterButtonText: "Apply", filterSelectTypes: { Equals: "Equals", + NotEquals: "Is not equal to", StartsWith: "StartsWith", Contains: "Contains", EndsWith: "EndsWith", GreaterThan: "Greater than", LessThan: "Less than", GreaterThanOrEquals: "Greater than or equals", - LessThanOrEquals: "Less than or equals" + LessThanOrEquals: "Less than or equals", + Null: "Is NULL", + NotNull: "Is not NULL" }, code: 'en', boolTrueLabel: "Yes", @@ -403,7 +407,7 @@ GridMvc.lang.en = { }; /*** * ============= FILTER WIDGETS ============= -* Filter widget allows onRender custom filter user interface for different columns. +* Filter widget allows onRender custom filter user interface for different columns. * For example if your added column is of type "DateTime" - widget can onRender calendar for picking filter value. * This script provider base widget for default .Net types: System.String, System.Int32, System.Decimal etc. * If you want to provide custom filter functionality - you can assign your own widget type for column and write widget for this types. @@ -458,9 +462,12 @@ TextFilterWidget = (function ($) { \ \ \
\ @@ -517,7 +524,7 @@ NumberFilterWidget = (function ($) { numberFilterWidget.prototype.onShow = function () { var textBox = this.container.find(".grid-filter-input"); - if (textBox.length <= 0) return; + if (textBox.length <= 0) return; textBox.focus(); }; @@ -538,6 +545,8 @@ NumberFilterWidget = (function ($) { \ \ \ + \ + \ \
\
\ @@ -626,10 +635,15 @@ DateTimeFilterWidget = (function ($) { \ \ \ + \ + \ \
' + (this.datePickerIncluded ? - '
' + '
\ +
\ + \ +
' : '
\ \ @@ -642,25 +656,25 @@ DateTimeFilterWidget = (function ($) { //if window.jQueryUi included: if (this.datePickerIncluded) { var datePickerOptions = this.data || {}; - datePickerOptions.format = datePickerOptions.format || "yyyy-mm-dd"; + datePickerOptions.format = datePickerOptions.format || "yy-mm-dd"; datePickerOptions.language = datePickerOptions.language || this.lang.code; + datePickerOptions.onSelect = function (date, ev) { + var type = $context.container.find(".grid-filter-type").val(); + var date = ev.input.datepicker("getDate"); + var newValue = $.datepicker.formatDate(datePickerOptions.format, date); + var filterValues = [{ filterType: type, filterValue: newValue }]; + $context.cb(filterValues); + } var $context = this; var dateContainer = this.container.find(".grid-filter-datepicker"); - dateContainer.datepicker(datePickerOptions).on('changeDate', function (ev) { - var type = $context.container.find(".grid-filter-type").val(); - //if (type == "1") { - // var tomorrow = new Date(ev.getTime()); - // tomorrow.setDate(ev.getDate() + 1); - // var filterValues = [{ filterType: type, filterValue: ev.format() }]; - //} - //else{ - var filterValues = [{ filterType: type, filterValue: ev.format() }]; - //} - $context.cb(filterValues); - }); - if (this.value.filterValue) - dateContainer.datepicker('update', this.value.filterValue); + dateContainer.datepicker(datePickerOptions); + if (this.value.filterValue) { + var date = $.datepicker.parseDate(datePickerOptions.format); + if (date) { + dateContainer.datepicker('update', this.value.filterValue); + } + } } }; @@ -713,7 +727,7 @@ BooleanFilterWidget = (function ($) { this.container.append(html); }; - booleanFilterWidget.prototype.registerEvents = function () { + booleanFilterWidget.prototype.registerEvents = function () { var $context = this; var applyBtn = this.container.find(".grid-filter-choose"); applyBtn.click(function () { @@ -733,4 +747,4 @@ BooleanFilterWidget = (function ($) { $(".grid-mvc").gridmvc(); }); }); -})(window.jQuery); \ No newline at end of file +})(window.jQuery); diff --git a/GridMvc.Site/Scripts/gridmvc.min.js b/GridMvc.Site/Scripts/gridmvc.min.js index 718a94b..4de6fa1 100644 --- a/GridMvc.Site/Scripts/gridmvc.min.js +++ b/GridMvc.Site/Scripts/gridmvc.min.js @@ -1 +1 @@ -window.pageGrids=window.pageGrids||{};$.fn.extend({gridmvc:function(){var n=[];return($(this).each(function(){if($(this).data("gridmvc"))n.push($(this).data("gridmvc"));else{var i={lang:$(this).attr("data-lang"),selectable:$(this).attr("data-selectable")=="true",multiplefilters:$(this).attr("data-multiplefilters")=="true"},t=new GridMvc(this,i),r=$(this).attr("data-gridname");r.length>0&&(window.pageGrids[$(this).attr("data-gridname")]=t);n.push(t);$(this).data("gridmvc",t)}}),n.length==1)?n[0]:n}});GridMvc=function(n){function t(t,i){this.jqContainer=n(t);i=i||{};this.options=n.extend({},this.defaults(),i);this.init()}return t.prototype.init=function(){this.lang=GridMvc.lang[this.options.lang];typeof this.lang=="undefined"&&(this.lang=GridMvc.lang.en);this.events=[];this.options.selectable&&this.initGridRowsEvents();this.filterWidgets=[];this.addFilterWidget(new TextFilterWidget);this.addFilterWidget(new NumberFilterWidget);this.addFilterWidget(new DateTimeFilterWidget);this.addFilterWidget(new BooleanFilterWidget);this.openedMenuBtn=null;this.initFilters()},t.prototype.initGridRowsEvents=function(){var n=this;this.jqContainer.on("click",".grid-row",function(){n.rowClicked.call(this,n)})},t.prototype.rowClicked=function(t){var i,r,u;t.options.selectable&&((i=n(this).closest(".grid-row"),i.length<=0)||(r={},i.find(".grid-cell").each(function(){var t=n(this).attr("data-name");t.length>0&&(r[t]=n(this).text())}),u=n.Event("RowClicked"),t.notifyOnRowSelect(r,u),u.isDefaultPrevented()||t.markRowSelected(i)))},t.prototype.markRowSelected=function(n){this.jqContainer.find(".grid-row.grid-row-selected").removeClass("grid-row-selected");n.addClass("grid-row-selected")},t.prototype.defaults=function(){return{selectable:!0,multiplefilters:!1,lang:"en"}},t.prototype.onRowSelect=function(n){this.events.push({name:"onRowSelect",callback:n})},t.prototype.notifyOnRowSelect=function(n,t){t.row=n;this.notifyEvent("onRowSelect",t)},t.prototype.notifyEvent=function(n,t){for(var i=0;i