This is for ASP.NET MVC
I have a grid that on scrolling hits the controller and does true sql paging. So each time you scroll it hits the controller that calls sql and gets the next 100 rows of data. This was working fine until we upgraded from a 2019 version of Kendo to the 2024.1.130.545 version. It all still works but as you scroll it gets slower and slower with each group of 100, the sql calls are all still fast but loading the data on the screen slows down exponentially on each set of 100.
This is the grid code we have set.
.NoRecords(x => x.Template("<div class='empty-grid' style='height: 300px; padding-top: 50px'>There are no units that match your search criteria. <br /><br /> Please expand your search criteria and try again.</div>"))
.Sortable(sortable => sortable.Enabled(true).SortMode(GridSortMode.SingleColumn))
.ColumnMenu()
.Resizable(resize => resize.Columns(true))
.Filterable(filterable => filterable
.Mode(GridFilterMode.Row)
.Extra(false)
.Operators(operators => operators
.ForString(str => str.Clear()
.Contains("Contains")
.StartsWith("Starts with")
.IsEqualTo("Is equal to")
.IsNotEqualTo("Is not equal to")
.DoesNotContain("Does Not Contain")
.EndsWith("Ends WIth")
.IsEmpty("Is Empty")
))
)
.Reorderable(reorder => reorder.Columns(true))
.Selectable(selectable => selectable
.Mode(GridSelectionMode.Single))
.Scrollable(scrollable => scrollable.Endless(false).Height(600))
.ToolBar(tools => tools.Excel())
.Excel(excel => excel
.FileName("UnitSearchExport.xlsx")
.Filterable(true)
.AllPages(true)
.ProxyURL(Url.Action("Excel_Export_Save", "Functions"))
)
.DataSource(dataSource => dataSource
.Ajax()
.AutoSync(false)
.ServerOperation(false)
.Model(model =>
{
var Modelinfo = new Infinity.Vehicle.Inventory.Vehicles_Listing.VehicleListInfo();
var Stock_Number = Modelinfo.Stock_Number;
model.Id(p => Stock_Number);
}))
.Events(e => e
.Filter("UnitInventoryListInfiniteScrollGrid_OnFiltering")
.Sort("UnitInventoryListInfiniteScrollGrid_OnSorting")
.ExcelExport("UnitInventoryListInfiniteScrollGrid_OnExcelExport")
.DataBound("UnitInventoryListInfiniteScrollGrid_OnDataBound")
))
Then on Scroll it basically does this.
In rich text editor does kendo support the layout column selection same as we have option in word like this
does kendo mvc rich text editor support that if yes please let us know how ?
I have a Form widget on a cshtml file:
@(Html.Kendo().Form<EditEraViewModel>() .Name("formEditEra") .HtmlAttributes(new { @method = "post" }) .Orientation("horizontal") .Layout("grid") .ButtonsTemplateId("buttonsTemplate") .Grid(g => g.Cols(1).Gutter(20)) .FormData(Model.EraViewModel) .Validatable(v => { v.ValidateOnBlur(false); v.ValidationSummary(vs => vs.Enable(false)); }) .Items(items => { .... }); }) .Events(ev => ev.Submit("EditEra.OnTestSubmit"))
I'm adding the button as a template, like this:
<script id="buttonsTemplate" type="text/x-kendo-template"> <div class="myButtonsContainer"> @if (!isImpersonating) { @(Html.Kendo().Button() .Name(@Localizer["general.page.button.submit"].ToString()) .HtmlAttributes(new { @class = "k-button k-button-md k-rounded-md k-button-solid k-button-solid-primary k-form-submit" }) .Content(@Localizer["general.page.button.submit"].ToString()) .Events(ev => ev.Click("EditEra.onFormSubmit")) .ToClientTemplate()) } @(Html.Kendo().Button() .Name(@Localizer["general.page.button.cancel"].ToString()) .HtmlAttributes(new { @class = "k-button k-button-md k-rounded-md k-button-solid k-button-solid-primary k-form-cancel" }) .Content(@Localizer["general.page.button.cancel"].ToString()) .Events(ev => ev.Click("goToProviderInfo")) .ToClientTemplate() ) </div> </script>
When the submit button is clicked, the OnPost method on the cshtml.cs file is not being triggered. It looks like the form is never submitted.
The "EditEra.OnTestSubmit" function that is called on the Submit event is being called. But the for is not being submitted, and the onPost method on the .cs file is never being executed.
What do I need to do to make sure that the form is submitted when the submit button is clicked?
Thanks.
I do
Hello Telerik Community,
I'm encountering an issue with my Kendo Chart implementation where certain data points are not displaying on the line series, despite being present in the dataset. Here's a breakdown of the problem and my current setup:
- Some data points, specifically those corresponding to the dates November 27 and November 29, are not showing up on the line chart.
- However, these dates are appearing correctly in the category legend.
- I'm using Kendo Chart to visualize historical pool data.
- Data is fetched from a database and processed in the controller before being passed to the Razor view for rendering.
- Each manufacturer's data is plotted on the chart as separate line series, with the x-axis representing dates and the y-axis representing weight.
- Controller Code: I've provided the relevant controller code responsible for fetching and processing the data.
- Razor View Code: Similarly, I've included the Razor view code where the Kendo Chart is defined and configured.
- I expect the line chart to display all data points, including those for November 27 and November 29, for each manufacturer.
- I've checked the data in the controller, and it seems that all data points are correctly fetched from the database.
- I've inspected the generated HTML for the chart and confirmed that the missing data points are indeed not being rendered.
- Could you please review my setup and help me identify any potential issues causing the missing data points?
- Additionally, if you have any suggestions for troubleshooting or debugging this issue further, I would greatly appreciate it.
- Framework: ASP.NET MVC- Browser: Chrome, Edge
Thank you in advance for your assistance!
public ActionResult ChartTMS(DateTime? fromDate, DateTime? toDate, string unit = "gm")
{
fromDate = fromDate?.Date;
toDate = toDate.HasValue ? toDate.Value.Date.AddDays(1).AddTicks(-1) : DateTime.Today;
if (!fromDate.HasValue || !toDate.HasValue)
{
fromDate = DateTime.Today.AddDays(-6);
toDate = DateTime.Today;
}
var allMeasurements = (
from m in db.Target_Measurement_History.AsNoTracking()
where m.Measurement_Record_Date >= fromDate.Value && m.Measurement_Record_Date <= toDate.Value
&& m.Target_Lot_Profile != null
&& m.Target_Lot_Profile.Target_Item != null
&& m.Target_Lot_Profile.Target_Item.Target_Manufacturer != null
select new MeasurementDataViewModel
{
Measurement_Record_Date = m.Measurement_Record_Date,
Pt_Remaining_Gms = m.Pt_Remaining_Gms,
Ru_Remaining_Gms = m.Ru_Remaining_Gms,
Manufacturer = m.Target_Lot_Profile.Target_Item.Target_Manufacturer,
}).ToList();
var manufacturers = allMeasurements.Select(m => m.Manufacturer).Distinct();
var colorMap = new Dictionary<string, string>();
Random rand = new Random();
foreach (var manufacturer in manufacturers)
{
colorMap[manufacturer] = $"#{rand.Next(0x1000000):X6}";
}
var groupedData = allMeasurements
.GroupBy(m => new { m.Measurement_Record_Date.Date, m.Manufacturer })
.Select(group => new MeasurementDataViewModel
{
Measurement_Record_Date = group.Key.Date,
Pt_Remaining_Gms = group.Sum(item => item.Pt_Remaining_Gms),
Ru_Remaining_Gms = group.Sum(item => item.Ru_Remaining_Gms),
Manufacturer = group.Key.Manufacturer,
Color = colorMap[group.Key.Manufacturer]
})
.OrderBy(g => g.Measurement_Record_Date)
.ThenBy(g => g.Manufacturer)
.ToList();
const float gramsPerTroyOunce = 31.1035f;
if (unit == "t oz")
{
foreach (var item in groupedData)
{
if (item.Pt_Remaining_Gms.HasValue)
item.Pt_Remaining_Gms = item.Pt_Remaining_Gms.Value / gramsPerTroyOunce;
if (item.Ru_Remaining_Gms.HasValue)
item.Ru_Remaining_Gms = item.Ru_Remaining_Gms.Value / gramsPerTroyOunce;
}
}
ViewBag.fromDate = fromDate;
ViewBag.toDate = toDate;
ViewBag.Unit = unit;
return View(groupedData);
}
public class MeasurementDataViewModel
{
public DateTime Measurement_Record_Date { get; set; }
public float? Pt_Remaining_Gms { get; set; }
public float? Ru_Remaining_Gms { get; set; }
public string Manufacturer { get; set; }
public string Color { get; set; }
}
[
{
"Measurement_Record_Date": "/Date(1542823200000)/",
"Pt_Remaining_Gms": 4370,
"Ru_Remaining_Gms": 5621,
"Manufacturer": "JX Nippon"
},
{
"Measurement_Record_Date": "/Date(1542823200000)/",
"Pt_Remaining_Gms": 4571,
"Ru_Remaining_Gms": 4295,
"Manufacturer": "Kojundo/Mitsui"
},
{
"Measurement_Record_Date": "/Date(1543168800000)/",
"Pt_Remaining_Gms": 1785,
"Ru_Remaining_Gms": 7086,
"Manufacturer": "JX Nippon"
},
{
"Measurement_Record_Date": "/Date(1543255200000)/",
"Pt_Remaining_Gms": 36432,
"Ru_Remaining_Gms": 41800,
"Manufacturer": "Kurt J. Lesker"
},
{
"Measurement_Record_Date": "/Date(1543428000000)/",
"Pt_Remaining_Gms": 76360,
"Ru_Remaining_Gms": 74687,
"Manufacturer": "Kurt J. Lesker"
},
{
"Measurement_Record_Date": "/Date(1543428000000)/",
"Pt_Remaining_Gms": 11138,
"Ru_Remaining_Gms": 9686,
"Manufacturer": "Materion"
},
{
"Measurement_Record_Date": "/Date(1543428000000)/",
"Pt_Remaining_Gms": 1329,
"Ru_Remaining_Gms": 4796,
"Manufacturer": "Mitsubishi"
}
]
@using Kendo.Mvc.UI
@using System.Web.Mvc
@using System.Web.Mvc.Html
@using Kendo.Mvc.Extensions
@model IEnumerable<TMS_RND.Controllers.MeasurementDataViewModel>
@using System.Web.Helpers
@{
ViewBag.Title = "Chart";
Layout = "~/Views/Shared/_Layout.cshtml";
DateTime startDate = ViewBag.fromDate ?? DateTime.Today.AddDays(-6);
DateTime endDate = ViewBag.toDate ?? DateTime.Today;
string currentUnit = ViewBag.Unit ?? "gm";
var manufacturers = Model
.GroupBy(m => m.Manufacturer)
.Select(g => new
{
Manufacturer = g.Key,
Color = g.First().Color
})
.ToList();
}
<div class="demo-section wide">
<div style="display: flex; justify-content: space-between; align-items: center;">
<div>
From: @(Html.Kendo().DatePicker().Name("fromDate").Value(startDate.ToString("yyyy-MM-dd")))
To: @(Html.Kendo().DatePicker().Name("toDate").Value(endDate.ToString("yyyy-MM-dd")))
<button id="refreshChart">Refresh Chart</button>
<button id="clearFilter">Clear</button>
<button id="toggleUnit">@(currentUnit == "gm" ? "Switch to Troy oz" : "Switch to gm")</button>
</div>
<div>
<button class="tab" id="totalPoolTab">Total Pool</button>
<button class="tab" id="tmsTab" style="background-color: lightblue;">TMS</button>
</div>
<div>
@foreach (var manufacturer in manufacturers)
{
<span style="color:@manufacturer.Color">@manufacturer.Manufacturer</span>
}
</div>
</div>
<div id="chartContainer">
@(Html.Kendo().Chart(Model)
.Name("chart")
.Title("Historical Pool Data")
.HtmlAttributes(new { style = "height: 400px;" })
.Legend(legend => legend.Position(ChartLegendPosition.Bottom))
.SeriesDefaults(seriesDefaults => seriesDefaults.Line().Stack(false))
.Series(series => {
foreach (var manufacturer in manufacturers)
{
var manufacturerData = Model.Where(m => m.Manufacturer == manufacturer.Manufacturer).ToList();
series.Line(manufacturerData.Select(m => m.Pt_Remaining_Gms))
.Name("Pt - " + manufacturer.Manufacturer)
.Color(manufacturer.Color)
.Visible(true)
.Labels(labels => labels.Visible(true).Format("{0:N2} " + currentUnit));
series.Line(manufacturerData.Select(m => m.Ru_Remaining_Gms))
.Name("Ru - " + manufacturer.Manufacturer)
.Color(manufacturer.Color)
.Visible(false)
.Labels(labels => labels.Visible(true).Format("{0:N2} " + currentUnit));
}
})
.CategoryAxis(axis => axis.Categories(Model.Select(m => m.Measurement_Record_Date.ToString("dd MMM yyyy")).Distinct()))
.ValueAxis(axis => axis.Numeric()
.Line(line => line.Visible(false))
.Title("Weight (" + currentUnit + ")"))
.Tooltip(tooltip => tooltip.Visible(true).Format("{0:N2} " + currentUnit))
)
</div>
</div>
<script>
$(document).ready(function () {
function toISOStringWithMidday(date) {
var localDate = new Date(date);
localDate.setHours(12, 0, 0, 0);
var offset = localDate.getTimezoneOffset() * 60000;
var localMidday = new Date(localDate.getTime() - offset);
return localMidday.toISOString();
}
$("#refreshChart").click(function () {
refreshChart();
});
$("#toggleUnit").click(function () {
var newUnit = '@currentUnit' == 'gm' ? 't oz' : 'gm';
refreshChart(newUnit);
});
$("#clearFilter").click(function () {
window.location.href = '@Url.Action("ChartTMS", "Target_Measurement_History")';
});
function refreshChart(newUnit) {
var selectedFromDate = $("#fromDate").data("kendoDatePicker").value();
var selectedToDate = $("#toDate").data("kendoDatePicker").value();
var unitParam = newUnit || '@currentUnit';
if (selectedFromDate && selectedToDate) {
var difference = Math.abs(selectedToDate.getTime() - selectedFromDate.getTime());
if (difference > 7 * 24 * 60 * 60 * 1000) {
alert("Please select a date range within 7 days.");
return;
}
var fromDateStr = toISOStringWithMidday(selectedFromDate);
var toDateStr = toISOStringWithMidday(selectedToDate);
window.location.href = '@Url.Action("ChartTMS", "Target_Measurement_History")' + '?fromDate=' + fromDateStr + '&toDate=' + toDateStr + '&unit=' + unitParam;
} else {
alert("Please select both from and to dates.");
}
}
$("#totalPoolTab").click(function() {
window.location.href = '@Url.Action("Chart", "Target_Measurement_History")';
});
$("#tmsTab").click(function() {
window.location.href = '@Url.Action("ChartTMS", "Target_Measurement_History")';
});
$("#tmsTab").css("background-color", "lightblue");
$(".tab").click(function() {
$(".tab").css("background-color", "");
$(this).css("background-color", "lightblue");
});
});
</script>
I have review this form discussions but cannot get this working.
How to add a delete button to editor template Grid Popup? in Kendo UI for jQuery | Telerik Forums
How can I add an additional update button inside of my grid popup editor template? I have the exact same requirements as discussed in
Add extra button to Grid popup editor template in UI for ASP.NET MVC | Telerik Forums
Perhaps little different as I am using a custom popup editor template called RecordEdit.cshtml as outlined in ASP.NET MVC Data Grid Component Use Custom Popup Editors - Telerik UI for ASP.NET MVC@(Html.Kendo().Grid//....
//....
.Events(ev=>ev.Edit("onEdit"))
.Editable
(
editable => editable.Mode(GridEditMode.PopUp)
.TemplateName("RecordEdit")
.Window(e => e.Width(1400).Height(1200))
)
)
function onEdit() {
$('<a class="k-button k-button-icontext k-grid-delete" href="\\#"><span class="k-icon k-delete"></span>Delete</a>').insertAfter(".k-grid-cancel");
}
I am unable to use the filter function i.e I am expecting when I click on the funnel to enter a text or something to take place i.e filtering however no option so far?
@model ReportViewModel
@using Kendo.Mvc.UI
@{
ViewBag.Title = "Report";
}
<link href="https://kendo.cdn.telerik.com/themes/6.4.0/default/default-ocean-blue.css" rel="stylesheet" type="text/css" />
<script src="https://kendo.cdn.telerik.com/2024.1.319/js/kendo.all.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2024.1.319/js/kendo.aspnetmvc.min.js"></script>
<style>
/* Basic styling for grids */
.k-grid {
width: 100%;
border-collapse: collapse;
}
/* Grid header styling */
.k-grid-header {
background-color: #f5f5f5;
border-bottom: 1px solid #ddd;
}
/* Grid header cell styling */
.k-grid-header th {
padding: 8px;
font-weight: bold;
text-align: left;
}
/* Grid body styling */
.k-grid tbody tr {
border-bottom: 1px solid #ddd;
}
/* Grid body cell styling */
.k-grid tbody td {
padding: 8px;
}
/* Alternate row background color */
.k-grid tbody tr:nth-child(even) {
background-color: #f9f9f9;
}
/* Hover effect for rows */
.k-grid tbody tr:hover {
background-color: #f0f0f0;
}
</style>
<h2>Employee and Location Report</h2>
<h3>Employees</h3>
@(Html.Kendo().Grid(Model.Employees)
.Name("gridEmployees")
.Columns(columns =>
{
columns.Bound(e => e.EmployeeId).Title("Employee ID");
columns.Bound(e => e.FirstName).Title("First Name");
columns.Bound(e => e.LastName).Title("Last Name");
columns.Bound(e => e.Department).Title("Department");
columns.Bound(e => e.Position).Title("Position");
columns.Bound(e => e.Salary).Title("Salary").Format("{0:C}");
})
.Pageable()
.Sortable()
.Filterable() // Enable filtering
)
<h3>Locations</h3>
@(Html.Kendo().Grid(Model.Locations)
.Name("gridLocations")
.Columns(columns =>
{
columns.Bound(l => l.LocationId).Title("Location ID");
columns.Bound(l => l.City).Title("City");
columns.Bound(l => l.Country).Title("Country");
columns.Bound(l => l.Address).Title("Address");
})
.Pageable()
.Sortable()
.Filterable()
)
Hi
My req is to save the documents in database in blob format. When user submits the form, the form will be saved in database and then with saved formid as reference key uploaded documents will be saved in documents table.
When user edits submitted form, I need to display already attached forms on the page. User may delete or attach new forms in edit screen.
When user viewing the form in read only mode, user should be able to download the form. How can i achieve this?
below code is working for uploading...
<div class="row col-md-12">
<div class="col-md-10">
<div class="form-group">
@Html.LabelFor(model => model.files, htmlAttributes: new { @class = "control-label col-md-4" })
<div class="col-md-8">
@(Html.Kendo().Upload()
.Name("files")
.Validation(validation => validation
.AllowedExtensions(new string[] { ".pdf", ".txt", ".xlsx", ".xls", ".doc", ".docx" })
.MaxFileSize(15728640)
.MinFileSize(3000))
.ShowFileList(true)
.HtmlAttributes(new { aria_label = "files" })
)
@Html.ValidationMessageFor(model => model.files, "", new { @class = "text-danger" })
</div>
</div>
</div>
</div>
viewmodel class
[Display(Name = "Upload relevant documents")]
public IEnumerable<HttpPostedFileBase> files { get; set; }
foreach (var file in vm.files)
{
byte[] document = new byte[file.ContentLength];
file.InputStream.Read(document, 0, file.ContentLength);
RLADOCUMENT rd = new RLADOCUMENT
{
RLAFORMID = (int)entity.ID,
DOCUMENTNAME = file.FileName,
CONTENTTYPE = file.ContentType,
DOCUMENTSIZE = document.Length,
DOCUMENTDATA = document,
CREATEDBY = Environment.UserName,
CREATEDDATE = DateTime.Now,
EXTENSION = Path.GetExtension(file.FileName)
};
_context.RLADOCUMENTS.Add(rd);
_context.SaveChanges();
}
Can someone help me how to display already attached files in Edit Mode with remove and upload option and download the attached reports.
My problem is that my MVC Grid was working up to Friday April 12, 2024, and now it's not. The Filter is causing my grid to error out. If I remove the Filter, my Grid works fine. If I use .Filterable(ftb => ftb.Mode(GridFilterMode.Row)), the Grid works fine.
What is causing my filtered grid not to work now? Below is my Grid:
@(Html.Kendo().Grid<AL.CC.DataContracts.DTO.Parts>()
.Name("PNGrid")
.Columns(columns =>
{
columns.Bound(p => p.Id).Hidden();
columns.Bound(p => p.pn).Width("150").Title("Part").Filterable(true);
columns.Bound(p => p.name).Width("150").Title("Name").Filterable(true);
columns.Bound(p => p.year).Width("150").Title("Year").Filterable(true);
})
.Selectable()
.Sortable(sortable => sortable.AllowUnsort(true).InitialDirection(System.ComponentModel.ListSortDirection.Descending).SortMode(GridSortMode.MultipleColumn))
.Scrollable(s => s.Enabled(true).Height("auto"))
.Resizable(resize => resize.Columns(true))
.AutoBind(true)
.HtmlAttributes(new { style = "width:100%; height:675px;" })
.Events(events => events.Change("Grid_OnRowSelect").DataBound("onDataBoundPN"))
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators => operators
.ForString(str => str.Clear()
.Contains("Contains")
))
)
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("GetAll_Read", "Maintenance"))
.ServerOperation(false)
.AutoSync(true)
.Model(model =>
{
model.Field(p => p.id).Editable(false);
model.Field(p => p.name).Editable(false);
model.Field(p => p.year).Editable(false);
model.Field(p => p.pn).Editable(false);
})
)
)
I'm also using the following scripts and css in the following order:
<link rel="stylesheet" href="https://code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-3.7.0.min.js" integrity="sha256-2Pmvv0kuTBOenSvLm6bvfBSSHrUJ+3A7x6P5Ebd07/g=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.20.0/jquery.validate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validation-unobtrusive/4.0.0/jquery.validate.unobtrusive.min.js"></script>
<script src="~/Scripts/kendo/2023.3.1114/jszip.min.js"></script>
<script src="~/Scripts/kendo/2023.3.1114/kendo.all.min.js"></script>
<script src="https://cdn.kendostatic.com/2023.3.1114/js/kendo.aspnetmvc.min.js"></script>
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js" integrity="sha256-lSjKY0/srUM9BE3dPm+c4fBo1dky2v27Gdjm2uoZaL0=" crossorigin="anonymous"></script>
<link href="https://kendo.cdn.telerik.com/themes/6.4.0/default/default-ocean-blue.css" rel="stylesheet" type="text/css" />
<link href="https://kendo.cdn.telerik.com/themes/6.4.0/bootstrap/bootstrap-main.css" rel="stylesheet" type="text/css" />
Hi,
How do I set the font size for items in a DropDownList?
I saw a tip suggesting the method below, but it hasn't worked for me.
k-popup .k-item {
font-size: 24px;
}
Please advise.
/Br Anders
Hello,
I can't get the Destroy method to work, I often get a 415 error with the GetListUsersDto object as parameters.
@(Html.Kendo().Grid<GetListUsersDto>().Name("GetListUsersGrid")
.Groupable()
.Sortable()
.Editable()
.Scrollable()
.ToolBar(x => x.Create())
.Columns(columns =>
{
columns.Bound(c => c.ID).Title(@Localizer["Tab_User_Id"].Value);
columns.Bound(c => c.Surname).Title(@Localizer["Editing_User_Surname"].Value);
columns.Bound(c => c.Firstname).Title(@Localizer["Editing_User_Firstname"].Value);
columns.Bound(c => c.RoleName).Title(@Localizer["Editing_User_Role"].Value);
columns.Bound(c => c.DateDebActif).Title(@Localizer["Editing_User_Start_Date"].Value).Format("{0:M/d/yyyy HH:mm:ss}"); ;
columns.Bound(c => c.DateFinActif).Title(@Localizer["Editing_User_End_Date"].Value).Format("{0:M/d/yyyy HH:mm:ss}"); ;
columns.Command(c =>
{
c.Edit();
c.Destroy();
});
}).DataSource(dataSource => dataSource.Ajax()
.Read(r => r.Action("getusers", "admin"))
.Create(r => r.Action("createuser", "admin"))
.Destroy(r => r.Action("deleteuser", "admin"))
.Model(model =>
{
model.Id(m => m.ID);
model.Field(f => f.ID).DefaultValue(Guid.NewGuid());
}
)).Pageable())
[HttpPost]
[Authorize(PolicyEnum.Administrateur)]
[Route("deleteuser")]
public string DeleteUser([DataSourceRequest] DataSourceRequest request, GetListUsersDto dto)
{
//var result = adminService.DeleteUser(dto.ID);
return JsonConvert.SerializeObject(new {/* error = result.IsError, message = localizer[result.IdMessage].Value + result.Message */});
}
public class GetListUsersDto
{
public Guid ID { get; set; }
public string Surname { get; set; }
public string Firstname { get; set; }
public string Username { get; set; }
public bool IsActif { get; set; }
public int RoleId { get; set; }
public string RoleName { get; set; }
public int LangId { get; set; }
public string LangName { get; set; }
public DateTime DateDebActif { get; set; }
public DateTime DateFinActif { get; set; }
}
If I change my GetListUsersDto method to Guid ID, the method works but the Guid is empty.
[HttpPost]
[Authorize(PolicyEnum.Administrateur)]
[Route("deleteuser")]
public string DeleteUser([DataSourceRequest] DataSourceRequest request, Guid Id)
{
//var result = adminService.DeleteUser(Guid.Parse(ID));
return JsonConvert.SerializeObject(new {/* error = result.IsError, message = localizer[result.IdMessage].Value + result.Message */});
}
If I only set a DataSourceRequest request, the method works, but doesn't return a usable object for my service.
[HttpPost]
[Authorize(PolicyEnum.Administrateur)]
[Route("deleteuser")]
public string DeleteUser([DataSourceRequest] DataSourceRequest request)
{
//var result = adminService.DeleteUser();
return JsonConvert.SerializeObject(new {/* error = result.IsError, message = localizer[result.IdMessage].Value + result.Message */});
}
I don't know what to do. Does anyone have a solution or idea?
Thank you,