Telerik Forums
UI for ASP.NET Core Forum
3 answers
139 views

Im having trouble with the KendoUI grid for .NETCore, always firing the create method.

Im using the edit inline template, expecting to fire the update method in the controller when the user updates a row.

Also the delete method is not being fired.

Basically made a helper class, put all the properties from 3 different models in a single class so i can handle it in the current form.

I think its something about not recognizing if its a new item on the grid, or a old item.

Any help would be greatly appreciated

  Helper class example(didnt add the whole class, bunch of int fields and strings):

 public class DJForm
    {
        
        public int Id { get; set; }

        
        [ScaffoldColumn(false)]
        public int? UserId { get; set; }

    
        [ScaffoldColumn(false)]
        public int LocationId { get; set; }

        [ScaffoldColumn(false)]
        public DateTime? ExposureMonth { get; set; }

        [ScaffoldColumn(false)]
        public string FiltrationUser { get; set; }

        [ScaffoldColumn(false)]
        public string PostWeighingUser { get; set; }

 
   }

Grid:

                  @(Html.Kendo().Grid<RTEMSDataLayer.UIResources.DJForm>()
                            .Name("grid")
                            .Columns(columns =>
                            {
                                columns.Bound(p => p.LocationJarId).Width(70).HeaderHtmlAttributes(new { style = "font color:black;font-size:x-small;height:auto;white-space:normal;text-align: center;font-weight:bold" });
                                columns.Bound(p => p.ExposureStartOn).Width(170).HeaderHtmlAttributes(new { style = "font-color:black;font-size:x-small;height:auto;white-space:normal;text-align: center;font-weight:bold" });
                                columns.Bound(p => p.ExposureEndOn).Width(170).HeaderHtmlAttributes(new { style = "font-color:black;font-size:x-small;width:170px;height:auto;white-space:normal;text-align: center;font-weight:bold" });
                                columns.Bound(p => p.FilterId).Width(95).HeaderHtmlAttributes(new { style = "font-color:black;font-size:x-small;height:auto;white-space:normal;text-align: center;font-weight:bold" });
                                columns.Bound(p => p.CrucibleNumber).Width(70).HeaderHtmlAttributes(new { style = "font-color:black;font-size:x-small;height:auto;white-space:normal;text-align: center;font-weight:bold" });
                                columns.Bound(p => p.LiquidSample).Width(70).HeaderHtmlAttributes(new { style = "font-color:black;font-size:x-small;height:auto;white-space:normal;text-align: center;font-weight:bold" });
                                columns.Bound(p => p.PreWeight).Width(70).HeaderHtmlAttributes(new { style = "font-color:black;font-size:x-small;height:auto;white-space:normal;text-align: center;font-weight:bold" });
                                columns.Bound(p => p.PostWeight).Width(70).HeaderHtmlAttributes(new { style = "font-color:black;font-size:x-small;height:auto;white-space:normal;text-align: center;font-weight:bold" });
                                columns.Bound(p => p.RowComment).Width(200).HeaderHtmlAttributes(new { style = "font-color:black;font-size:x-small;height:auto;white-space:normal;text-align: center;font-weight:bold" });
                                columns.Command(command => { command.Edit(); command.Destroy(); }).Width(100);
                            })
                            .ToolBar(toolbar => toolbar.Create())
                            .Editable(editable => editable.Mode(GridEditMode.InLine))
                            .Pageable()
                            .Sortable()
                            .Scrollable()
                            .HtmlAttributes(new { style = "height:430px;" })
                            .DataSource(dataSource => dataSource
                                .Ajax()
                                .PageSize(30)
                                .Events(e => e.Error("error_handler"))
                            .Model(model =>
                            {
                                model.Id(p => p.Id);                             
                            })
                                .Create(update => update.Action("EditingInline_Create", "DustJarDatas").Data("additionalData"))
                                .Read(read => read.Action("EditingInline_Read", "DustJarDatas"))
                                .Update(update => update.Action("EditingInline_Update", "DustJarDatas"))
                                .Destroy(update => update.Action("EditingInline_Destroy", "DustJarDatas"))
                            )
                    )

Update Action:

        [AcceptVerbs("Post")]
        public IActionResult EditingInline_Update([DataSourceRequest] DataSourceRequest request, DJForm form)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("error", "error");
                return Json(new[] { form }.ToDataSourceResult(request, ModelState));
            }

            if (form != null && ModelState.IsValid)
            {
                //DustJarData dj = _context.DustJarData.Find(form.LocationJarId);

                //dustjardata.LocationJarId = form.LocationJarId;
                //dustjardata.ExposureStartOn = dateExpStart;
                //dustjardata.ExposureEndOn = dateExpEnd;
                //   productService.Update(p);
            }

            return Json(new[] { form }.ToDataSourceResult(request, ModelState));
        }

Create Action example:

public IActionResult EditingInline_Create(string data, [DataSourceRequest] DataSourceRequest request, DJForm form)
        {
            string[] rawData = data.Split(',');
            if (rawData[0] != null) {
                form.UserId = Int32.Parse(rawData[0]);
            }
            if (rawData[1] != null) {
                form.LocationId = Int32.Parse(rawData[1]);
            }
            if (rawData[2] != null) {
                form.ExposureMonth = DateTime.Parse(rawData[2]);
            }
            if (rawData[3] != null) {
                form.FiltrationUser = rawData[3];
            }
            if (rawData[4] != null) {
                form.PostWeighingUser = rawData[4];
            }
            if (rawData[5] != null) {
                form.ProcessSessionOn = DateTime.Parse(rawData[5]);
            }
            if (rawData[6] != null) {
                form.WeighingSessionOn = DateTime.Parse(rawData[6]);
            }
            if (rawData[7] != null) {
                form.ProcessTemp = Int32.Parse(rawData[7]);
            }
            if (rawData[8] != null)
            {
                form.ProcessRh = Int32.Parse(rawData[8]);
            }
            if (rawData[9] != null)
            {
                form.WeighingTemp = Int32.Parse(rawData[9]);
            }
            if (rawData[10] != null)
            {
                form.WeighingRh = Int32.Parse(rawData[10]);
            }

            if (!ModelState.IsValid) {
                ModelState.AddModelError("101", "errors");
                ViewBag.Error = "102";
                return Json(new[] { form }.ToDataSourceResult(request, ModelState));
            }

            if (form != null && ModelState.IsValid)
            {

....

....

....

}

Tsvetina
Telerik team
 answered on 17 Aug 2017
1 answer
182 views

Hello,

I need to show in a grid a ModelView of a complex object, with about 50 different fields.

If editing in inline or popup mode, I would need to scroll to much (horizontally or vertically) so I need to build a completely personalized form to insert/update data.

How is it possible to link to a personalized view from a EDIT/ADD buttons from the asp.net core grid?

And how to pass the mode (Insert or Update) and the ID (for Update operations) to this view?

Have you a sample code?

Thanks a lot,

Davide

Preslav
Telerik team
 answered on 15 Aug 2017
3 answers
314 views

The drop-down list loads the text before the value is loaded, and the text and value are not synchronized

The digital text box loads the text box first, and then loads the up and down arrow styles, whether it can be done asynchronously or simultaneously, rather than requiring two changes to complete the display

As shown in Figure 1 and Figure 2, when the page is loaded, the scene appears
1, flash down after the figure 2, the amount of data is not large, there will be this situation, whether it can directly display the effect of Figure 2

 

How can you load the process shown in Figure 1, with the progress bar display, and so on, the process of Figure 1 loaded finished, shown in Figure 2

Ivan Danchev
Telerik team
 answered on 14 Aug 2017
2 answers
117 views

 Hello there,
I have used Table of Content in ReportBook and its working perfectlu but my problem is I want that Page containgin that TOC is at 3rd possition of ReportBook.
As we have to add that TOC contained page as TocReportSource to add into ReportBook and its adding that page at first index automatically.
Kidnly please help me out with this.

 

 

 

Stefan
Telerik team
 answered on 14 Aug 2017
4 answers
212 views
demo:
<div id="exampleWrap">
        <script>$("#exampleWrap").css("visibility", "hidden");</script>

        @{
            <div id="example">
                @RenderBody()
            </div>

            if (ViewBag.Description != null)
            {
                <div class="box demo-description wide">
                    <h4>Description</h4>
                    @Html.Raw(ViewBag.Description)
                </div>
            }
        }
        <script>
            $(function(){ $("#exampleWrap").css("visibility", ""); });
        </script>
    </div>
But in the data show that before the emergence of white
How can you determine the data( @RenderBody()) before the end of the load with the progress bar displayed, the data hidden after the progress bar?
Konstantin Dikov
Telerik team
 answered on 14 Aug 2017
6 answers
204 views

Please refer to the screen cast link below.  During inline editing when the time column is clicked to begin editing the existing time is cleared.  Also after the time and then entering the am pm designator the time is cleared and the editor closes.  Entering a time is actually only possible when the DateTime model property is marked as nullable otherwise a validation error is thrown.  (All in the video)

Grid:

@(Html.Kendo().Grid<Aero.Models.Leg>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.FlightID);    
        columns.Bound(p => p.Origin);
        columns.Bound(p => p.Destination);
        columns.Bound(p => p.Start); 
        columns.Bound(p => p.TakeOff);
        columns.Bound(p => p.Landing);
        columns.Bound(p => p.Stop);
    })
    .ToolBar(toolBar =>
    {
        toolBar.Save();
        toolBar.Create();
    })
    .Editable(editable => editable.Mode(GridEditMode.InCell))
    .Scrollable()
    .Resizable(resize => resize.Columns(true))
    .HtmlAttributes(new { style = "height:430px;" })
    .DataSource(dataSource => dataSource
        .Ajax()
        .Batch(true)
        .PageSize(20)
        .ServerOperation(false)  
        .Model(model =>
        {
            model.Id(p => p.LegID);
            model.Field(p => p.LegID).Editable(false);         
        })
        .Read(read => read.Action("Legs_Read", "Test", new {  id = Model.FlightID }))
        .Update(update => update.Action("Legs_Update", "Test"))
        //.Create(create => create.Action("ForeignKeyColumn_Create", "Grid"))
        //.Destroy(destroy => destroy.Action("ForeignKeyColumn_Destroy", "Grid"))
    ).Deferred()
)

 

Model:

   public class Leg

    {
        public int LegID { get; set; }

        [DataType(DataType.Time)]     
        public DateTime? Start { get; set; }

        [DataType(DataType.Time)]  
        public DateTime? Stop { get; set; }

        [DataType(DataType.Time)]
         public DateTime TakeOff { get; set; }

        [DataType(DataType.Time)]       
        public DateTime Landing { get; set; } 

        public string Origin { get; set; }
        public string Destination { get; set; }

        public string Notes { get; set; }

        [Display(Name = "Flight")]
        public int? FlightID { get; set; }
        public virtual Flight Flight { get; set; }
    }

https://screencast-o-matic.com/watch/cbiQc1lbrz

Reafidy
Top achievements
Rank 2
Iron
 answered on 12 Aug 2017
10 answers
626 views

DropDownList  The binding indicates that the data is delayed

The first step shows the value

Second step display text

Joana
Telerik team
 answered on 11 Aug 2017
1 answer
146 views
How in core do we add the "All" page size option, there is no list<object> overload it just wants an array of ints.
Georgi
Telerik team
 answered on 10 Aug 2017
5 answers
307 views
Hello,
I am trying use this example http://demos.telerik.com/aspnet-core/grid/detailtemplate to insert a grid within another grid. However, I am getting an error of "Invalid Tempate". I have included a screen shot of both the error and the code I am using for the grid.
Pavlina
Telerik team
 answered on 09 Aug 2017
1 answer
188 views

How can I add the sum of a column to the pageing footer like in this example:

https://s3.amazonaws.com/telerik-media/telerik-videos/controls/grid-bootstrap-fallback.jpg

I would like to replace the text in the picture "56 cars matching your criteria"  with "Total Price: $x.xx"

Viktor Tachev
Telerik team
 answered on 09 Aug 2017
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?