HI All,
A custom request got me spinning and wondering if any of you came across it and have a solution for me.
A NumericTextBox in the a grid column.
1. Show the exact value keyed in by the user.
Eg. 12.12345, 23.55, 76.590
2. Value could have decimal precision up to 5 places
3. If the user enter 1.1, it should display 1.10. (showing 1 trailing 0 in the case)
I have solution to 1 and 2, but not 3.
I tried using template: "#=kendo.toString(OrderQuantity,'n2')#" for the column, It will show 2 decimal places like I wanted, but it's rounded and not what the user entered.
TIA
I am using Asp.net core on the , in my controller I have the following code
[HttpPost]
public IActionResult GetUsers(string search)
{
var result = new List<UserDto>
{
new UserDto
{
UserId = 1,
FirstName = "jhon",
LastName = "doe",
UserName = "jhond",
Email = "jhond@AOL.com"
},
new UserDto
{
UserId = 2,
FirstName = "james",
LastName = "bond",
UserName = "jamesd",
Email = "jamesd@gmail.com"
}
};
var data = new DataSourceResult
{
Total = 2,
Data = result
};
return Json(data);
}
Now my DataSourceResult object looks like this
public class DataSourceResult<T>
{
/// <summary>
/// Extra data
/// </summary>
public object ExtraData { get; set; }
/// <summary>
/// Data
/// </summary>
public T Data { get; set; }
public bool Success => !Errors.Any();
/// <summary>
/// Errors
/// </summary>
public List<string> Errors { get; set; } = new List<string>();
public Exception Exception { get; set; }
/// <summary>
/// Total records
/// </summary>
public int Total { get; set; }
}
public class DataSourceResult : DataSourceResult<object>
{
}
My view has this code inside
<div id="gridUserInfo"></div>
$(document).ready(() => {
$("#gridUserInfo").kendoGrid({
dataSource: {
transport: {
read: {
url: "/User/GetUsers",
type: "POST",
dataType: "json",
data: function() {
var data = {
search: $('#search').val()
};
return data;
}
}
},
schema: {
data: "Data",
total: "Total",
errors: "Errors",
model: {
id: "userId",
fields: {
firstName: { editable: false, type: "string" },
lastName: { editable: false, type: "string" },
userName: { editable: false, type: "string" },
email: { editable: false, type: "string" }
}
}
}
},
height: 550,
columns: [
{
field: "firstName",
title: "First Name"
},
{
field: "lastName",
title: "Last Name"
},
{
field: "userName",
title: "UserName"
},
{
field: "email",
title: "Email"
}
],
pageable: {
pageSizes: [10, 20, 30],
buttonCount: 5
}
});
}
After making a POST to my UserControllerI get the following json
{
"extraData"
:
null
,
"data"
:[{
"userId"
:1,
"firstName"
:
"jhon"
,
"lastName"
:
"doe"
,
"email"
:
"jhond@AOL.com"
,
"userName"
:
"jhond"
},{
"userId"
:2,
"firstName"
:
"james"
,
"lastName"
:
"bond"
,
"email"
:
"jamesd@gmail.com"
,
"userName"
:
"jamesd"
}],
"success"
:
true
,
"errors"
:[],
"exception"
:
null
,
"total"
:2}
But it is not displaying that information on the grid, What am I doing wrong?
Hi,
my customer like the kendo panelbar and has a wish:
Round edge and a little space between the titles, similar to the Accordion
Do you have some css code to adapt the appearance of the panelbar?
Dojo with the used bootstrap v3 theme: https://dojo.telerik.com/OzeMENIY
Best regards,
Peter
Hi all,
I try to set a default value for a numeric field. I can't figure out why it does not work.
I simply set default value this way : schema.model.fields.MyNumericField to {defaultValue : 9, type:"number"}.
All I get when I create a record is 0.
I join screenshot of entire schem model.
Thanks in advance for any help,
André.
I know how to use dynamic columns with kendo. You just load the data before and then add columns, but I am having hard time using template with them.
The template function has its own scope, and when generating the values,I can't get the kendo.htmlEncode(data.fieldValue).
Example
https://dojo.telerik.com/ujaqoNIp
Hello,
I have kendo mvvm grid which is grouped . How can i delete item from grid easily?
Below is code to delete item from grid i found from various sources, in that 'index' gives incorrect number after grid is inserted or deleted with other items later on
var
tstgrid = $(e.currentTarget).closest(
"[data-role='grid']"
).data(
"kendoGrid"
);
$(e.target).closest(
"tr"
).trigger(
"click"
);
var
index = tstgrid.items().index(tstgrid.select());
ImportPNRPricingViewModel.Tsts._data.splice(index, 1);
to insert we, use $.merge, 'ImportPNRPricingViewModel' is my observable and 'response' has new items
$.merge(response, ImportPNRPricingViewModel.Tsts.data());
ImportPNRPricingViewModel.Tsts.data(response);