Ejemplo n.º 1
0
        public JsonResult GetSearchResults(string sidx, string sord, int page, int rows, bool _search, string filters)
        {
            //Placements tbl = new Placements();
            int pageIndex   = Convert.ToInt32(page) - 1;
            int pageSize    = rows;
            int currentPage = pageIndex * pageSize == 0 ? 1 : pageIndex * pageSize;

            int         totalRecords = tbl.Count();
            int         totalPages   = (int)Math.Ceiling((float)totalRecords / (float)pageSize);
            jgridFilter searchRules  = jgridFilter.Create(filters ?? "");
            bool        IsSearch     = _search;

            string where_string = "";



            if (IsSearch)
            {
                string groupOp = searchRules.groupOp;
                int    i       = 0;
                foreach (Rule myrule in searchRules.rules)
                {
                    string line = BuildLine(myrule.op, myrule.field, myrule.data);

                    if (i == 0)
                    {
                        where_string = line;
                    }
                    else
                    {
                        where_string += " " + groupOp + " " + line;
                    }

                    i++;
                }
            }//


            IEnumerable <dynamic> results;

            if (IsSearch)
            {
                results = tbl.Paged(where : where_string, orderBy: sidx + " " + sord, currentPage: currentPage, pageSize: pageSize).Items;
            }
            else
            {
                results = tbl.Paged(orderBy: sidx + " " + sord, currentPage: currentPage, pageSize: pageSize).Items;
            }

            JsonResult myJasonResults = GetJson(results, totalPages, page, totalRecords);

            return(myJasonResults);
        }
Ejemplo n.º 2
0
        public JsonResult DynamicGridData(string sidx, string sord, int page, int rows, bool _search, string filters)
        {
            //note: a view is used here. This is because the we want to display the PUBLICATION_NETWORK field from the PUBLICATION_NETWORKS table
            //OID_PUBLISHER_ID field of the  MEDIA_CAT_DIGITAL_PLCMNT table is hooked up to a combo box: ref method PublishersCombo() which feeds the combo box
            //if just the data from the MEDIA_CAT_DIGITAL_PLCMNT table was to be dispayed you could simply pass in the Placements class like so:
            //SearchHelper sh = new SearchHelper(new Placements(), ShapeGridRow);

            //display a view
            DynamicModel       myview = new View_Placements_Publications();
            jgridDisplayHelper sh     = new jgridDisplayHelper(myview, ShapeGridRow);

            int pageIndex    = Convert.ToInt32(page) - 1;
            int pageSize     = rows;
            int totalRecords = tbl.Count(); //repository.TimeCards.Count();
            int totalPages   = (int)Math.Ceiling((float)totalRecords / (float)pageSize);



            JsonResult mydata = sh.GetSearchResults(sidx, sord, page, rows, _search, filters);

            return(mydata);
        }