Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't reload data #188

Open
jamessuske1985 opened this issue May 27, 2019 · 2 comments
Open

Can't reload data #188

jamessuske1985 opened this issue May 27, 2019 · 2 comments

Comments

@jamessuske1985
Copy link

Hi all, I have a grid like so, this gets populated on a post method which works fine, but when I change the post data, I am expecting the same grid but with other data and it appears not to do that, I get the same data from the initial post, so how do I update the data?

[Authorize]
        [HttpPost]
        public ActionResult Index(DateTime? BatchDate, string Desc, string Usr, int Batches)
        {

            List<ClosingHeaderClass> headers = webService.LSH_ClosingHeaderGetAll();

            ViewData["headers"] = headers;

            ViewBag.user = user;
            ViewBag.Batches = Batches;
            ViewBag.Desc = Desc;
            ViewBag.BatchDate = BatchDate.ToString().Split(' ')[0];

            ClosingHeaderAddClass closing = new ClosingHeaderAddClass();

            GridDefinition<ClosingDetailsClass> def = new GridDefinition<ClosingDetailsClass>();

            GridColumn<ClosingDetailsClass> ID = new GridColumn<ClosingDetailsClass>();
            ID.ColumnName = "ID";
            ID.HeaderText = "ID";
            ID.HtmlEncode = false;
            ID.ValueTemplate = "<input type='text' name='ID' value='{Value}' />";
            ID.ValueExpression = (i, c) => i.ID.ToString();
            def.AddColumn(ID);

            GridColumn<ClosingDetailsClass> Seq = new GridColumn<ClosingDetailsClass>();
            Seq.ColumnName = "Seq";
            Seq.HeaderText = "Seq";
            Seq.HtmlEncode = false;
            Seq.ValueTemplate = "<input type='text' name='Seq' value='{Value}' />";
            Seq.ValueExpression = (i, c) => i.Seq.ToString();
            def.AddColumn(Seq);

            GridColumn<ClosingDetailsClass> job = new GridColumn<ClosingDetailsClass>();
            job.ColumnName = "Job";
            job.HeaderText = "Job";
            job.HtmlEncode = false;
            job.ValueTemplate = "<input type='text' name='Job' value='{Value}' />";
            job.ValueExpression = (i, c) => i.Job;
            def.AddColumn(job);

            GridColumn<ClosingDetailsClass> cc = new GridColumn<ClosingDetailsClass>();
            cc.ColumnName = "CC";
            cc.HeaderText = "Cost Code";
            cc.HtmlEncode = false;
            cc.ValueTemplate = "<input type='text' name='CC' value='{Value}' />";
            cc.ValueExpression = (i, c) => i.CC;
            def.AddColumn(cc);

            GridColumn<ClosingDetailsClass> date = new GridColumn<ClosingDetailsClass>();
            date.ColumnName = "Date";
            date.HeaderText = "Date";
            date.HtmlEncode = false;
            date.ValueTemplate = "<input type='text' name='Date' value='{Value}' class='datepicker' />";
            date.ValueExpression = (i, c) => i.Date.Split(' ')[0];
            def.AddColumn(date);

            if (Batches == 0)
            {
                ClosingHeaderAddClass item = webService.LSH_ClosingHeaderAdd(BatchDate, Desc, Usr);

                closing = webService.LSH_ClosingHeaderGet(item.ID);

                def.RetrieveData = (options) =>
                {
                    return new QueryResult<ClosingDetailsClass>()
                    {
                        Items = webService.LSH_ClosingDetailsGetBatch(item.ID),
                        TotalRecords = 0
                    };
                };


            }
            else
            {
                ClosingHeaderAddClass item = webService.LSH_ClosingHeaderGet(Batches);

                closing = webService.LSH_ClosingHeaderGet(item.ID);

                def.RetrieveData = (options) =>
                {
                    return new QueryResult<ClosingDetailsClass>()
                    {
                        Items = webService.LSH_ClosingDetailsGetBatch(item.ID),
                        TotalRecords = 0
                    };
                };
            }

            try
            {
                MVCGridDefinitionTable.GetDefinition<ClosingDetailsClass>("NonFluentUsageExample");
            }
            catch (Exception e)
            {
                MVCGridDefinitionTable.Add("NonFluentUsageExample", def);
            }

            return View(closing);
        }
@jamessuske1985
Copy link
Author

Anyone?

@jamessuske1985
Copy link
Author

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant