Hi,
We have a little problem with control @html.kendo().CurrencyTextBox. We have a view where we have definite a CurrencyTextBox, this view is called from a grid from method .EditorTemplateName(“View”)
I send you two images, one image in Internet Explorer with correct format and another from Mozilla Firefox.
Now I show you the code grid from main view:
01.@(Html.Kendo().Grid<ValoritzablesViewModel>()02. .Name("refundables")03. .HtmlAttributes(new { style = "height: 100%; border: 0;" })04. .ToolBar(t =>05. {06. if (User.IsInRole("Modify"))07. {08. t.Save().SaveText("Validar");09. }10. })11. .Columns(columns =>12. {13. columns.ForeignKey(f => f.CentreID, (System.Collections.IEnumerable)ViewBag.Centres, "ContactID", "Nom").Width(120);14. columns.ForeignKey(f => f.CycleID, (System.Collections.IEnumerable)ViewBag.BillingCycles, "OptionID", "Name").EditorTemplateName("CustomGridForeignKey").Width(90);15. columns.Bound(f => f.CodFact).Width(100);16. columns.Bound(f => f.ProductorName);17. columns.Bound(f => f.DataServei).Width(100);18. columns.Bound(f => f.ServiceID).Width(80);19. columns.Bound(f => f.RefExt).Width(80);20. columns.Bound(f => f.DocNum).Width(100);21. columns.ForeignKey(f => f.Reference, (System.Collections.IEnumerable)ViewBag.CatalegResidus, "Value", "Text");22. columns.Bound(f => f.Quantitat).Width(80);23. columns.Bound(f => f.Preu).ClientTemplate("#: kendo.toString(data.Preu, 'C2') # (" + 24. "# if (data.RefundFare == " + (short)fareType.Custom + ") { #Contracte" +25. "# } else if (data.RefundFare == " + (short)fareType.Standard + ") { #Standard" +26. "# } else if (data.RefundFare == " + (short)fareType.Premium + ") { #Premium" +27. "# } else if (data.RefundFare == " + (short)fareType.AdHoc + ") { #Puntual" +28. "# } else { #General" +29. "# } #)").EditorTemplateName("RefundFare").Width(350);30. columns.Template(@<text></text>)31. .ClientTemplate("<input type='checkbox' #= Generate ? checked='checked':'' # class='chkbx' />")32. .HeaderTemplate("<input type='checkbox' id='checkAllRecords' onclick='checkAll(this)' />")33. .Width(36);34. })35. .Editable(editable =>36. {37. if (User.IsInRole("Modify"))38. {39. editable.Mode(GridEditMode.InCell);40. }41. else42. {43. editable.Enabled(false);44. }45. })46. .Pageable(pageable => pageable.Refresh(true))47. .Scrollable()48. .Sortable()49. .Filterable()50. .DataSource(dataSource => dataSource51. .Ajax()52. .Batch(true)53. .PageSize(30)54. .Model(model =>55. {56. model.Id(a => a.DetailID);57. model.Field(f => f.CentreID).Editable(false);58. model.Field(f => f.ServiceID).Editable(false);59. model.Field(f => f.DataServei).Editable(false);60. model.Field(f => f.RefExt).Editable(false);61. model.Field(f => f.DocNum).Editable(false);62. model.Field(f => f.ProductorName).Editable(false);63. model.Field(f => f.CodFact).Editable(false);64. model.Field(f => f.CycleID).Editable(false);65. model.Field(f => f.Reference).Editable(false);66. model.Field(f => f.Quantitat).Editable(false);67. })68. .Events(e => e69. .Error(@<text>70. function (e) {71. onError(e, "refundables");72. }73. </text>)74. .RequestEnd(@<text>75. function (e) {76. onRefundRequestEnd(e);77. }78. </text>))79. .Sort(s => s.Add(f => f.DataServei).Descending())80. .Read("RefundRead", "Payments")81. .Update("RefundValidate", "Payments")82. )83. )
And for finish I show you code with view RefundFare with CurrencyTextBox control:
01.@using SGI2014.Models;02.@model object03. 04.<script type="text/javascript">05. var row = $(event.srcElement).closest("tr");06. var grid = $(event.srcElement).closest("[data-role=grid]").data("kendoGrid");07. var currentDataItem = grid.dataItem(row);08. 09. function onPreuChange() {10. @*var radios = document.getElementsByName("RefundFare");11. for (i = 0; i < radios.length; i++) {12. radios[i].checked = (radios[i].value == @((short)fareType.AdHoc));13. }*@14. @*var radio = $("input[value='@((short)fareType.AdHoc)']");15. radio.prop("checked", true);16. currentDataItem.RefundFare = @((short)fareType.AdHoc);*@17. currentDataItem.set('RefundFare', @((short)fareType.AdHoc));18. currentDataItem.set('Generate', true);19. grid.refresh();20. }21. 22. function onRefundFareClick(e) {23. //var ctb = $("#Preu").data("kendoNumericTextBox");24. if (e.value == @((short)fareType.AdHoc)) {25. //ctb.value("");26. //currentDataItem.Preu = 0;27. currentDataItem.set('Preu', 0);28. } else {29. $.ajax({30. cache: false,31. url: '@Url.Action("GetFarePrice", "Payments")',32. //data: { fare: e.value, detailID: getParentID() },33. data: { fare: e.value, detailID: currentDataItem.DetailID },34. success: function (received) {35. //ctb.value(received);36. //currentDataItem.Preu = received;37. currentDataItem.set('Preu', received);38. }39. })40. }41. currentDataItem.set('Generate', true);42. grid.refresh();43. }44. 45. //function getParentID() {46. // var row = $(event.srcElement).closest("tr");47. // var grid = $(event.srcElement).closest("[data-role=grid]").data("kendoGrid");48. // var currentDataItem = grid.dataItem(row);49. // return currentDataItem.DetailID;50. //}51.</script>52. 53.@(Html.Kendo().CurrencyTextBox()54. .Name("Preu")55. .HtmlAttributes(new { style = "width:100px" })56. .Events(e => e.Change("onPreuChange"))57.)58. 59.<input type='radio' name='RefundFare' value='@((short)fareType.Standard)' onclick="onRefundFareClick(this)">Standard60.<input type='radio' name='RefundFare' value='@((short)fareType.Premium)' onclick="onRefundFareClick(this)">Premium61.<input type='radio' name='RefundFare' value='@((short)fareType.Custom)' onclick="onRefundFareClick(this)">Contracte62.<input type='radio' name='RefundFare' value='@((short)fareType.AdHoc)' onclick="onRefundFareClick(this)">Puntual
Thanks in advance.
Xavier de la Rubia.
Hello all,
I have a problem with save one row. Here is my code:
DataSource:
var localDataSource = new kendo.data.DataSource({ batch: true, transport: { read: function (options) { $.ajax({ url: "Content/JSON/GridData.json", success: function (result) { options.success(result); }, error: function (result) { options.error(result); } }); }, update: function (options) { console.log("update call"); options.success(); } }, schema: { model: { id: "Id", fields: { Name: "Name", Position: "Position" } } } });
Kendo grid:
var grid = $("#grid").kendoGrid({ dataSource: localDataSource, editable: true, toolbar: ["save", "cancel"], columns: [ { command: { name: "saveOneRow", text: "save", click: function (e) { var row = $(this).closest('tr'); grid.editRow(row); grid.saveChanges(); // save all } }, title: " ", width: "180px" }, { field: "Name", width: "100px", title: "Name" }, { field: "Position", width: "100px", title: "Position" }, ], }).data('kendoGrid');
Save all and cancel all works fine.
But how can I save one row?
(because localDataSource.sync() (save all) and localDataSource .read() (cancel all).)
p.s. I tried command {name: "save"}, but he didn`t fire any event
Thanks
I want to use the date category axis which should only show years:
@(Html.Kendo().Chart().Name("CompetenceEvolution")
.SeriesDefaults(sd => sd.Line().Style(ChartLineStyle.Smooth))
.Series(series =>
{
foreach (var data in Model.EvolutionChartData)
{
series.Line(data.Items).Field("Score").CategoryField("AssessmentDate").Name(data.Name);
}
})
.CategoryAxis(axis => axis.Date().BaseUnit(ChartAxisBaseUnit.Years))
...
but I would like that for plotting the points the real date is used (now the point is placed above the category label), but is should be placed according to the date. Because now, when having two different items in the same year (with a different date), only one item is getting plotted to the chart.
Ok my requirement is simple and I am just getting lost in the various partial examples and forum posts on how to do this. What is surprising is I would expect this to be so standard there would hundreds of examples out there but I cannot find one.
I have a basic person model with properties to include a birthdate. All of those properties are on a grid in a MVC 5 Razor view. The grid is setup and works fine. What I would like to do is keep the existing filter capability on the birthdate field but add four additional filters that signify age groupings, so one for under 11 years old, one for between 11 and 14, and one for between 14 and 18, and one for over 18.
Then of course since this is not a field in the actual database, I would need to do "custom server binding" as all the partial examples somewhat show. I have played with the datasourcerequest object in the past and I have no need to implement a fill blown custom binding scenario. Is it possible to just intercept these four requests, pull them out of the IFilterDescriptors, apply them manually, and then pass the remaining request object to the ToDataSourceResult method?
If so I have not seen this either. If someone could please guide me to the right area on this I would appreciate it. To sum up:
1. How do you add custom filters to the grid menu on a column but keep the default ones there?
2. Can you intercept these filters and pull them out of the filter descriptor collection?
3. How would you identify these custom filters to pull them out?
I have a kendogrid:
@(Html.Kendo().Grid<OAIWebInterface.Models.Leadership>()
.Name("LeadershipGrid")
.Columns(columns =>
{
columns.Bound(c => c.LeadershipID).Width(150);
columns.Bound(c => c.Organization).Width(150);
columns.Command(command => { command.Edit(); }).Width(95);
})
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("LeadershipEditorTemplate"))
.HtmlAttributes(new { style = "max-height: 350px;" })
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(p => p.LeadershipID))
.Read(read => read.Action("Leadership_Read", "AnnualSummary", new { ASId = Model.AnnualSummaryID}))
.Update(update => update.Action("LeadershipPopup_Update", "AnnualSummary"))
)
)
I have a Editor Template called "LeadershipEditorTemplate" in which I got the following code:
@Html.RadioButtonFor(x => x.Reimburse, true)Yes
@Html.RadioButtonFor(x => x.Reimburse, false)No
On edit kendo row, one of the radio buttons in the editor template do not get checked. For example, Yes should be checked when the Reimburse value is true/1 and No should be checked when the value is set to false/0.
I verified that Reimbuse has a value when in template, but can't make it work with radio buttons.
I would appreciate any input on this issue.
Thanks.
Hello
I have question how to refresh control after edit?
I tried:
public JsonResult Update([DataSourceRequest] DataSourceRequest request, ProductCategoryViewModel category) { if (ModelState.IsValid) { var services = new ProductCategoryServices(db); services.Update(category, ModelState); } var result = db.ProductCategories.ToTreeDataSourceResult(request, cat => cat.ProductCategoryId , cat => cat.FKParentProductCategoryId , cat => cat.ToProductCategoryViewModel(request) ); return Json(category, JsonRequestBehavior.AllowGet); // return Json(new[] { category }.ToTreeDataSourceResult(request, ModelState)); }PS. Stupid question but where is edit post option? :)
Hi Team,
I am using kendo UI editor and image browser in MVC View in form of HTML. I have to upload an image. I have created one action method and bound to the upload function of image browser. When i upload, image gets saved to the location and after that an automatic thumbnail call goes to app which has a url and pass the path parameter which is the file name. In case of new file upload it pass the path value to undefined. In upload action i am returning json response in form of:
var json = new { name = Path.GetFileName(file.FileName),
type = "f",
size = file.ContentLength
};
return Json(json, "text/plain");
Thumbnail action method is the default action method of EditorImageBrowserController class which i am using.
Please let me know if i am missing anything or do i need to override thumbnail action. If yes please provide me example.
Thanks.

Hi,
Is it possible, that dataSource.sync(); causes a double postback if using a slow connection ?
It looks like that the client postback twice if the server doesn't reply within e.g. 15 seconds.
The code:
var dataSource = $("#" + gridname).data("kendoGrid").dataSource;dataSource.sync();Are there any good ways to prevent double postbacks using the kendo framework?
Thanks.