예제 #1
0
        private IList <YourCustomSearchClass> SearchFunction(
            DataTableAjaxPostModel model
            , out int filteredResultsCount
            , out int totalResultsCount
            )
        {
            var searchBy = model.search?.value;
            var take     = model.length;
            var skip     = model.start;
            var userId   = model.userid;

            var sortBy  = "";
            var sortDir = true;

            if (model.order != null)
            {
                // in this example we just default sort on the 1st column
                sortBy  = model.columns[model.order[0].column].data;
                sortDir = model.order[0].dir.ToLower() == "asc";
            }

            if (searchBy == null)
            {
                // if any of the columns have server-side search set on them (not all of them should!)
                // use the search string provided with the column to perform server side searching.
            }


            // search the dbase taking into consideration table sorting and paging
            var result = _auditTrailService.GetDataFromDbase(
                userId
                , searchBy
                , take
                , skip
                , sortBy
                , sortDir
                , out filteredResultsCount
                , out totalResultsCount
                );


            if (result == null)
            {
                // empty collection...
                return(new List <YourCustomSearchClass>());
            }

            return(result);
        }