I have the below example:
As you can see, I check and pre Save Changes, everything works ok. I check, hit Cancel Changes and we get back to its original state.
After I save/commit to the db and then hit cancel changes, the grid updates some check boxes (incorrectly) and also updates the items.
What's going on here?!
Here's my grid code
@(Html.Kendo().Grid<BinWithType>
()
.Name("gridBins")
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => {
model.Id(p => p.Bin_ID);
model.Field(p => p.SiteHasBin).Editable(true);
model.Field(p => p.Bin_Type_Name).Editable(false);
model.Field(p => p.Bin_Type_Group).Editable(false);
})
.Batch(true)
.ServerOperation(false)
.Read("Bins_Read", "MySites", new { site_Id = Model.Site_Id })
.Update("Bins_Update", "MySites", new { site_Id = Model.Site_Id })
)
.Columns(columns =>
{
columns.Bound(site => site.SiteHasBin).Filterable(false);
columns.Bound(site => site.Bin_Type_Name).Filterable(false);
columns.Bound(site => site.Bin_Type_Group).Filterable(filterable => filterable.UI("groupFilter"));
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators => operators
.ForString(str => str.Clear()))
)
.Sortable()
.ToolBar(toolbar =>
{
toolbar.Save();
})
)
Further strange behaviour:
When I do a 'standard' batch update this works as expected see first half of gif above. However, when I do one by one, I appear to just replicate the first.
Here is my my Read & Update code:
public ActionResult Bins_Read(int site_Id, [DataSourceRequest]DataSourceRequest request)
{
return Json(Read(site_Id).ToDataSourceResult(request));
}
public IEnumerable<BinWithType> Read(int siteId)
{
return GetAllAsync(siteId).Result.ToList();
}
public async Task<IList<BinWithType>> GetAllAsync(int siteId)
{
if (Session.GetObjectFromJson<IList<BinWithType>>("BinWithType") != null)
{
Session.Remove("BinWithType");
_session.Clear();
}
var result = Session.GetObjectFromJson<IList<BinWithType>>("BinWithType");
var client = new BinsClient(new HttpClient());
var bins = await client.GetBinsWithTypeBySiteIdAsync(siteId);
result = bins.ToList();
Session.SetObjectAsJson("BinWithType", result);
return result;
}
public ActionResult Bins_Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")] IEnumerable<BinWithType> bins)
{
var client = new BinsClient(new HttpClient());
foreach (var bin in bins)
{
if (bin.Bin_ID > 300)
{
DeleteBin(bin, client);
}
if (bin.Bin_ID < 300)
{
PostNewBin(bin, client);
}
}
return Json(Read(bins.FirstOrDefault().Site_ID).ToDataSourceResult(request));
}
private static Task<Bin> DeleteBin(BinWithType bin, BinsClient client)
{
return client.DeleteBinByIdAsync(bin.Bin_ID);
}
[HttpPost]
private static Task<Bin> PostNewBin(BinWithType bin, BinsClient client)
{
var thisBin = new Bin
{
Site_ID = bin.Site_ID,
Bin_Type_ID = bin.Bin_Type_ID,
Comments = $"Added { DateTime.Now.ToShortDateString() }"
};
return client.PostBinAsync(thisBin);
}
Hey everybody,
I'm experimenting with the Kendo Forms and I recognized that building/rendering the form with razor all labels showing the property name itself instead the display name I set in the model.
@(Html.Kendo().Form<Provider>()
.Name("form")
.Validatable(v =>
{
v.ValidateOnBlur(true);
v.ValidationSummary(vs => vs.Enable(false));
})
.Items(items =>
{
items.Add().Field(x => x.Description).Editor(x => x.Editor());
items.Add().Field(x => x.Url);
})
)
My model has set a display name for the properties.
public class Provider
{
[Display(Name = "Kurzbeschreibung")]
public string Description { get; set; }
[Display(Name = "Link zur Website")]
public string Url { get; set; }
}
I am using a nested grid. The nested grid is inside of script tags and looks like this. For some reason when rendering it throws "Unexpected Token '<'. Im unsure why. It renders fine if I pull it out and remove .ToClientTemplate()
<script id="template">
@(Html.Kendo().Grid<Student>()
.Name("Student#=Student_ID#")
.Width(1500)
.HtmlAttributes(new { style="margin-right:20px;height: fit-content;font-size:small" })
.Columns(columns =>
{
columns.Bound(o => o.StudentName).Width(300)
columns.Bound(o => o.TimeStamp).Width(300).Title("Date").Format("{0:G}");
columns.Bound(o => o.Details).Width(900);
})
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.PageSize(10)
.Read(read => read.Action("GetDetails", "Grid", new{ studentName= "#=StudentName#" }))
)
.Pageable(x => x.Refresh(true))
.Sortable()
.ToClientTemplate()
)
</script>
Is there a way to create an Combobox in the PanelBar header? We want to reload content of the PanelBar after changing the Combobox value.
I haven't found a function or Property like HeaderTemplate() or something similar.
I have a web application that I am adding additional functions to. The File Manager has just about everything I need (except to hide create folders). But users have to have the ability to download files. (I kind of don't get how you can have a file manager without the ability to download files.)
Users will upload some CSV files, start a process & at end of process download log files created by the process.
I see an example of how to extend File Manger but it just doesn't seem to fit the razor page model. Can anyone point me towards some good examples of how to add that in?
Is Server side paging supported on Treelist control?
It seems like Pager automatically dissaper when ServerOperation flag is true.
Thanks in advance.
In my project asp .Net 5.0 Core, I have the next problem when my page load.
unable to resolve service for type 'kendo.mvc.rendering.kendo html generator'
Index.cshtml
I used the telerik package telerik.ui.for.aspnet.core.2021.2.616
In _ViewImports
@using WASys
@using WASys.Models
@using Kendo.Mvc.UI
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Kendo.Mvc
<kendo-grid name="grid" height="550">
<columns>
<column field="ID" title="Order ID">
<filterable enabled="false"></filterable>
</column>
<column field="CodigoInterno" title="Codigo" />
<column field="NombreLargo" title="Nombre Producto/Servicio" />
<column field="PrecioCosto" title="Precio Costo" />
</columns>
<scrollable enabled="true" />
<sortable enabled="true" />
<pageable enabled="true" />
<filterable enabled="true" />
<datasource type="DataSourceTagHelperType.Ajax" page-size="20">
<transport>
<read url="@Url.Action("Orders_Read", "AlmacenProductosServicios")" />
</transport>
</datasource>
</kendo-grid>
I am using the FileManager in ASP.net CORE 5 using the Tag Helpers. I created a partial view for the FileManager and created a controller to handle the Read, Upload, Destroy, Create.... Currently the read and upload functions work as expected, but when I try to delete a file I Am getting 415 Error using this Tag:
<destroy url="/FileManagerData/Destroy" type="POST" />
Here is the response:
{"type":"https://tools.ietf.org/html/rfc7231#section-6.5.13","title":"Unsupported Media Type","status":415,"traceId":"00-cd48a67e3165574bb55f025789ec2570-d50282d662ca804c-00"}
After some research the it appears the 415 and Unsupported Media Type is caused by not passing in the Content Type, so I changed the Tag to this:
<destroy url="/FileManagerData/Destroy" type="POST" content-type="multipart/form-data" />
This produced a 400 error with a response of:
{"errors":{"":["Failed to read the request form. Missing content-type boundary."]},"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"One or more validation errors occurred.","status":400,"traceId":"00-c95edcb44f53ca4aa80654e8ac3f4d6b-80784c169952f14a-00"}
According to you docs the content-type is application/x-www-form-urlencoded which gives me the 415 error.
Here is the Destroy Method from the Controller:
[HttpPost("Destroy")]
public virtual ActionResult Destroy(FileManagerEntry entry)
{
var path = NormalizePath(entry.Path);
if (!string.IsNullOrEmpty(path))
{
if (entry.IsDirectory)
{
DeleteDirectory(path);
}
else
{
DeleteFile(path);
}
return new JsonResult(new object[0]);
}
throw new Exception("File Not Found");
}
What am I missing here to get this to work?
[UPDATE]
I Change the Destroy Method in the controller to this:
public virtual ActionResult Destroy([FromForm] FileManagerEntry entry)
Added [FromForm] Which now produces the following validation errors:
{"errors":{"Created":["The value 'Mon Aug 16 2021 10:06:38 GMT-0500 (Colombia Standard Time)' is not valid for Created."],"Modified":["The value 'Mon Aug 16 2021 10:06:38 GMT-0500 (Colombia Standard Time)' is not valid for Modified."],"CreatedUtc":["The value 'Mon Aug 16 2021 10:06:38 GMT-0500 (Colombia Standard Time)' is not valid for CreatedUtc."],"ModifiedUtc":["The value 'Mon Aug 16 2021 10:06:38 GMT-0500 (Colombia Standard Time)' is not valid for ModifiedUtc."]},"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"One or more validation errors occurred.","status":400,"traceId":"00-5bc6f05eed3360458a9c5f37a37c8f11-27e6c765b081e642-00"}
[UPDATE 1]
I Created my own Model to replace the FileManagerEntry but set all the DateTime Fields to Strings:
public class FileDataJTE
{
public string Name { get; set; }
public string Path { get; set; }
public string Extension { get; set; }
public bool IsDirectory { get; set; }
public bool HasDirectories { get; set; }
public string Created { get; set; }
public string CreatedUtc { get; set; }
public string Modified { get; set; }
public string ModifiedUtc { get; set; }
}
Then I Had to pass that in to the Method and convert and string ie Create, back to DateTime:
[HttpPost("Destroy")]
Why does this not work with the FileManagerEntry on a Controller?
Any ideas on this or am I even on the right track to get this working?
Thanks
--R