public ActionResult GetItems(GridParams g, bool collapsed)
        {
            //passing 2 Functions MakeFooter and MakeHeader to customize header and add footer

            var builder =
                new GridModelBuilder <Lunch>(Db.Lunches.AsQueryable(), g)
            {
                Key        = "Id",
                Map        = o => new { o.Id, o.Person, o.Food, Date = o.Date.ToShortDateString(), o.Price, o.Location, ChefName = o.Chef.FirstName + " " + o.Chef.LastName },
                MakeFooter = MakeFooter,
                MakeHeader = gr =>
                {
                    //get first item in the group
                    var first = gr.Items.First();

                    //get the grouped column value(s) for the first item
                    var val = string.Join(" ", AweUtil.GetColumnValue(gr.Column, first).Select(ToStr));

                    return(new GroupHeader
                    {
                        Content = string.Format(" {0} : {1} ( Count = {2}, Max Price = {3} )",
                                                gr.Header,
                                                val,
                                                gr.Items.Count(),
                                                gr.Items.Max(o => o.Price)),
                        Collapsed = collapsed
                    });
                }
            };

            return(Json(builder.Build()));
        }
        public ActionResult GetItems(GridParams g)
        {
            return(Json(new GridModelBuilder <Lunch>(Db.Lunches.AsQueryable(), g)
            {
                Map = o => new
                {
                    o.Person,
                    o.Price,
                    o.Food,
                    Date = o.Date.ToString("dd MMMM yyyy"),
                    o.Location,
                    o.Organic,
                    RowClass = o.Price > 90 ? "pinkb" : o.Price < 30 ? "greenb" : string.Empty
                },
                MakeHeader = gr =>
                {
                    var value = AweUtil.GetColumnValue(gr.Column, gr.Items.First()).Single();
                    var strVal = gr.Column == "Date" ? ((DateTime)value).ToString("dd MMMM yyyy") :
                                 gr.Column == "Price" ? value + " GBP" : value.ToString();

                    return new GroupHeader {
                        Content = gr.Header + " - " + strVal
                    };
                }
            }.Build()));
        }
示例#3
0
        private GridModel <variable_vw> BuildGridModel(GridParams g)
        {
            // retreive Session info created when selections were made to mpre-map grid
            Dictionary <string, string> GroupedIds = Session["PreMap_GroupedIds"] as Dictionary <string, string>;

            var dt = ado.GetVariable_vw(GroupedIds);

            return(new GridModelBuilder <variable_vw>(dt.AsQueryable(), g)
            {
                // same as pre-map setup
                Key = "nid",
                //Map = o => new { o.Id, o.Person, o.Food, o.Date, o.Price, o.Location, ChefName = o.Chef.FirstName + " " + o.Chef.LastName },
                MakeFooter = MakeFooter,
                MakeHeader = gr =>
                {
                    //get first item in the group
                    var first = gr.Items.First();

                    //get the grouped column value(s) for the first item
                    var val = string.Join(" ", AweUtil.GetColumnValue(gr.Column, first).Select(ToStr));

                    return new GroupHeader
                    {
                        Content = string.Format(" {0} : {1} ( Count = {2}, <input type='checkbox' name='id' value='{3}'/> )",
                                                gr.Header,
                                                val,
                                                gr.Items.Count(),
                                                //gr.Items.Max(o => o.delta)
                                                null),
                        Collapsed = false
                    };
                }
            }.Build());
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gridId"></param>
        /// <param name="ctxid">use context prefix, default true</param>
        /// <returns></returns>
        public MovableRowsCfg DropOn(string gridId, bool ctxid = true)
        {
            if (ctxid)
            {
                gridId = AweUtil.GetContextPrefix(awe.Html) + gridId;
            }

            ids.Add(gridId);

            return(this);
        }
示例#5
0
        /// <summary>
        /// Set the defaults for awem.js and jquery.validate (if present) by calling utils.init;
        /// sets date format, first day of week, decimal separator, isMobileOrTablet
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="ahtml"></param>
        /// <returns></returns>
        public static IHtmlString Init <T>(this AwesomeHtmlHelper <T> ahtml)
        {
            var isMobileOrTablet = Autil.IsMobileOrTablet(ahtml) ? 1 : 0;
            var dateFormat       = AweUtil.ConvertTojQueryDateFormat(Autil.CurrentCulture().DateTimeFormat.ShortDatePattern);
            var decimalSep       = Autil.CurrentCulture().NumberFormat.NumberDecimalSeparator;

            var sb = new StringBuilder("<script>");

            sb.AppendFormat("awem.isMobileOrTablet = function() {{ return {0}; }};", isMobileOrTablet);
            sb.AppendFormat("awem.fdw = {0};", (int)Autil.CurrentCulture().DateTimeFormat.FirstDayOfWeek);
            sb.AppendFormat("utils.init('{0}', {1}, '{2}')", dateFormat, isMobileOrTablet, decimalSep);
            sb.Append("</script>");

            return(new HtmlString(sb.ToString()));
        }
        public ActionResult GetItems(GridParams g, int[] abc, bool collapsed)
        {
            //passing 2 Functions MakeFooter and MakeHeader to customize header and add footer
            try
            {
                var builder = new GridModelBuilder <variable_vw>(db.variable_vw.AsQueryable(), g)
                {
                    Key = "Id",
                    //Map = o => new { o.Id, o.Person, o.Food, o.Date, o.Price, o.Location, ChefName = o.Chef.FirstName + " " + o.Chef.LastName },
                    MakeFooter = MakeFooter,
                    MakeHeader = gr =>
                    {
                        //get first item in the group
                        var first = gr.Items.First();

                        //get the grouped column value(s) for the first item
                        var val = string.Join(" ", AweUtil.GetColumnValue(gr.Column, first).Select(ToStr));

                        return(new GroupHeader
                        {
                            Content = string.Format(" {0} : {1} ( Count = {2}, Max Price = {3} )",
                                                    gr.Header,
                                                    val,
                                                    gr.Items.Count(),
                                                    //gr.Items.Max(o => o.delta)
                                                    null),
                            Collapsed = collapsed
                        });
                    }
                };

                var j = builder.Build();

                return(Json(j));
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                return(null);
            }
        }
示例#7
0
        public ActionResult GetItems(GridParams g, bool collapsed)
        {
            //passing 2 Functions MakeFooter and MakeHeader
            return(Json(new GridModelBuilder <Lunch>(Db.Lunches.AsQueryable(), g)
            {
                MakeFooter = MakeFooter,
                MakeHeader = gr =>
                {
                    //get first item in the group
                    var first = gr.Items.First();

                    //get the grouped column value for the first item
                    var val = AweUtil.GetColumnValue(gr.Column, first).Single();

                    return new GroupHeader
                    {
                        Content = string.Format(" {0} : {1} ( Count = {2}, Max Price = {3} )",
                                                gr.Header, val, gr.Items.Count(), gr.Items.Max(o => o.Price)),
                        Collapsed = collapsed
                    };
                }
            }.Build()));
        }
示例#8
0
        // End JSTree


        /// <summary>
        /// get the items for the main PreMapping grid
        /// <param name="g"></param>
        /// <param name="abc"></param>
        /// <param name="collapsed"></param>
        /// <param name="IDList"></param>
        /// <returns></returns>
        public ActionResult GetItems(GridParams g, int[] abc, bool collapsed, string IDList, string search)
        {
            search = (search ?? "").ToLower();

            if (!string.IsNullOrEmpty(IDList))
            {
                Entities            db  = new Entities();
                DATA.MicaRepository ado = new DATA.MicaRepository();
                IDList = IDList.Replace("[", "");
                IDList = IDList.Replace("]", "");
                IDList = IDList.Replace("\"", "");

                //List<string> nodes = IDList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                String[] nodearray = IDList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray();


                // the last item was most recently selected-- find its children and add to the list
                //  ********

                Dictionary <string, string> GroupedIds = new Dictionary <string, string>();
                string lastgroup = null;

                foreach (string item in nodearray)
                {
                    if (item.Contains('_'))  // skip top level item, it does not have a node id
                    {
                        string[] i = item.Split('_');
                        if (i[0] != lastgroup)
                        {
                            // ned to build something like this:   (a.tids REGEXP '^243|_243' or a.tids REGEXP '^244|_244')
                            try
                            {
                                GroupedIds.Add(i[0], "a.tids REGEXP " + "'^" + i[1] + "|_" + i[1] + "'");
                            }
                            catch (ArgumentException)
                            {
                                string cur;
                                // remove the current item that is already in the dictionary; group items into a single string and Add back
                                GroupedIds.TryGetValue(i[0], out cur);
                                GroupedIds.Remove(i[0]);
                                GroupedIds.Add(i[0], cur + " or a.tids REGEXP " + "'^" + i[1] + "|_" + i[1] + "'");
                            }
                        }
                    }
                }

                //passing 2 Functions MakeFooter and MakeHeader to customize header and add footer
                try
                {
                    // add this selection to Session
                    Session["PreMap_GroupedIds"] = GroupedIds;
                    Session["PreMap_search"]     = search;

                    //var dt = db.variable_vw.ToList().Where(o => nodes.Contains(o.nid.ToString()));
                    var dt = ado.GetVariable_vw(GroupedIds).Where(o => o.study_name.ToLower().Contains(search));

                    int cnt = dt.Count();
                    ViewBag.CNT = cnt;

                    //var builder = new GridModelBuilder<variable_vw>(db.variable_vw.AsQueryable(), g)
                    var builder = new GridModelBuilder <variable_vw>(dt.AsQueryable(), g)
                    {
                        Key = "nid",
                        //Map = o => new { o.Id, o.Person, o.Food, o.Date, o.Price, o.Location, ChefName = o.Chef.FirstName + " " + o.Chef.LastName },
                        MakeFooter = MakeFooter,
                        MakeHeader = gr =>
                        {
                            //get first item in the group
                            var first = gr.Items.First();

                            //get the grouped column value(s) for the first item
                            var val = string.Join(" ", AweUtil.GetColumnValue(gr.Column, first).Select(ToStr));

                            string content_str = null;
                            if (gr.Column == "field_label_value")
                            {
                                content_str = " <font color='darkslateblue'><b>{0} ({2})</b> : {1} <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Item Description</b>: {3} </font> )";
                            }
                            else
                            {
                                content_str = " <font color='darkslateblue'><b>{0} ({2})</b> : {1} </font>";
                            }


                            return(new GroupHeader
                            {
                                //Content = string.Format(" <font color='darkslateblue'><b>{0}</b> : {1} &nbsp;&nbsp;&nbsp; <b>Count</b> = {2} <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Item Description</b> = {3} </font> )",
                                Content = string.Format(content_str,
                                                        gr.Header,
                                                        val,
                                                        gr.Items.Count(),
                                                        gr.Items.Max(o => o.body_value)
                                                        //gr.Items.Count(),
                                                        //gr.Items.Max(o => o.delta)
                                                        //null
                                                        ),
                                Collapsed = collapsed
                            });
                        }
                    };

                    var j = builder.Build();

                    return(Json(j));
                }
                catch (Exception ex)
                {
                    string message = ex.Message;
                    return(null);
                }
            }
            return(null);
        }