mleibman / SlickGrid

A lightning fast JavaScript grid/spreadsheet
http://wiki.github.com/mleibman/SlickGrid
MIT License
6.82k stars 1.98k forks source link

compileFilter() fails when filter function is used with ASP.NET Bundling and Minification #1053

Open nothingisnecessary opened 9 years ago

nothingisnecessary commented 9 years ago

The .replace() calls in compileFilter() and compileFilterWithCaching() (slick.dataview.js) fail to replace the return true and return false statements in the user-defined filter function if the user-defined filter function is in a script file that has been bundled by ASP.NET Bundling and Minifcation (System.Web.Optimization).

Reason: ASP.NET replaces return true with return!0 and return false with return!1 (this happens even if you call BundleTable.Transforms.Clear(), so possibly part of Bundling routine rather than Minification routine).

Confirmed workarounds: 1) options.inlineFilters = false (to avoid using compiled filters altogether) 2) Do not use ASP.NET B&M for the file with the filter function, OR 3) Modify slick.dataview.js to handle the special cases for return values.

Suggested fix: I considered doing a fork&pull request, but not sure if support for "ASP.NET bundling" is a goal of this project (though it seems that there was already a fix to compileFilter() to handle JS compression method used by Google).

Related StackOverflow question: http://stackoverflow.com/questions/27702628/script-minified-with-bundling-dont-work-in-asp-net-mvc-3-when-debugging-is-disa

6pac commented 9 years ago

This has been integrated into my 'alternative master'. Any testing is appreciated. See https://github.com/mleibman/SlickGrid/issues/1055