Irsf provides the list, sorting, and filtering functions quickly and easily.

Source: Internet
Author: User

Irsf is written in Javascript. irsf implements the list, sorting, and filtering functions (RSF) quickly and easily ).

Irsf consists of three classes.

Irsfsource data source irsffilter filter irsfsorter Sorter

Irsf usage:

Irsf = new irsf (); irsf. draw = function (data) {// display list. The data structure is {property: [{data1}, {data2}]}. * property can be customized, specified by irsfsource .}; // Specify the data source irsf. setsource ({SRC: {items: [{ID: 1121, name: "DFSA" },{ ID: 1122, name: "DFSA"}]}, property: "items"}); // Add the filter irsf. addfilter ("ID", function (ROW) {return row. id = 1121;}); // sets the irsf. setsort (function (a, B) {return. id-b.id;}); // execute and redraw the list will call irsf. draw method irsf. records ();

Irsf source code:

/*** Display list, sorting, and filtering (RSF) * irsf quick and easy-to-use list, sorting, filtering, and other functions * User: oshine * Date: 13-7-30 * Time: */function irsfsource (setting) {This. property = setting. property | "items"; this. src = setting. SRC | {}; this. clonepropertylist = function () {var tmp_data = []; for (var I in this. SRC [this. property]) {tmp_data [I] = This. SRC [this. property] [I];} return tmp_data;}; this. clone = function (){ VaR result = {}; var tmp_data = This. clonepropertylist (); return result [this. property] = tmp_data;} function irsffilter () {This. filters = {}; this. filtering = function (src_data) {var ret = [], I = src_data.length-1; For (; I> = 0; I --) {var flag = true; for (var j in this. filters) {var fn_filter = This. filters [J]; If (typeof fn_filter = "function") {flag = Flag & fn_filter (src_data [I]);} If (! Flag) {break;} If (FLAG) {ret. push (src_data [I]) ;}} return ret ;}; this. clearfilters = function () {for (var j in this. filters) {This. filters [J] = NULL; delete this. filters [J] ;}} function irsfsorter () {This. sort = NULL; this. sorting = function (src_data) {If (this. sort = undefined | this. sort = NULL | typeof this. sort! = "Function") {return src_data;} src_data.sort (this. sort); Return src_data ;}} function irsf () {This. isource = new irsfsource ({SRC :{}, property: "items"}); this. sorter = new irsfsorter (); this. filter = new irsffilter (); this. draw = NULL; this. setsource = function (setting) {This. isource. src = setting. SRC | {}; this. isource. property = setting. property | "items" ;}; this. records = function () {var $ Data = This. isource. clonepropertylist (); $ DATA = This. filter. filtering ($ data); $ DATA = This. sorter. sorting ($ data); var result = {}; Result [this. isource. property] = $ data; If (this. draw! = Undefined & this. Draw! = NULL & typeof this. draw = "function") {This. draw (result);} return result;}; this. addfilter = function (name, filter) {This. filter. filters [name] = filter;}; this. removefilter = function (name) {If (this. filter. filters [name] = undefined) {return true;} This. filter. filters [name] = NULL; delete this. filter. filters [name]; return true;}; this. setsort = function (SORT) {This. sorter. sort = sort;}; this. clearsort = function () {This. sorter. sort = NULL ;}}

  

  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.