- Home
- Forum
- ASP.NET MVC
- updateRecord on multiple page
updateRecord on multiple page
Hi, I have 2 questions
Q1
I have a Grid and want to update a field of all record in client-side by press a button.
this is a grid
@(Html.EJ().GridPromozioneDettaglio>("GridDetailPromo") .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.dsDetail).CrudURL("DetailCrud").Adaptor(AdaptorType.RemoteSaveAdaptor)) .Query("new ej.Query().where('tipoArticolo', 'equal', 'TtipoServizio', false)") .SortSettings(sort => sort.SortedColumns(col => col.Field("descrizione").Direction(SortOrder.Ascending).Add())) .ToolbarSettings(tool => tool.ShowToolbar().ToolbarItems(tbItem => { if (!disableControls & (ruolo == "ADMIN" || ruolo == "SUPERUSER")) { tbItem.AddTool(ToolBarItems.Add); tbItem.AddTool(ToolBarItems.Edit); tbItem.AddTool(ToolBarItems.Delete); tbItem.AddTool(ToolBarItems.Update); tbItem.AddTool(ToolBarItems.Cancel); } })) .Locale("it-IT") .AllowSorting() .AllowPaging() .AllowSelection() .PageSettings(page => page.PageSize(10)) .IsResponsive(true) .EnableResponsiveRow(true) .MinWidth(400) .EditSettings(edit => { edit.AllowAdding();//enebled adding edit.AllowDeleting();//enabled deleting edit.AllowEditing();//enabled editing edit.AllowEditOnDblClick(!disableControls & (ruolo == "ADMIN" || ruolo == "SUPERUSER"));//disabled editing when record is double clicked edit.EditMode(EditMode.Normal);//setting edit mode edit.ShowDeleteConfirmDialog();//enabling api to show confirmation dialog upon deleting }) .Columns(col => { col.Field(c => c.tipoArticolo).HeaderText("Tipo articolo").Visible(false).Add(); col.Field(c => c.ID).HeaderText("ID").Visible(false).IsPrimaryKey(true).Add(); col.Field(c => c.IDarticolo).HeaderText("Articolo").ForeignKeyField("ID").ForeignKeyValue("descrizione").DataSource(ViewBag.dsServizi).Add(); col.Field(c => c.sconto).HeaderText("Sconto %").Width("15%").Format("{0:N} %").TextAlign(TextAlign.Right).ValidationRules(v => v.AddRule("required", true).AddRule("number", true).AddRule("range", "[0,100]")).Add(); }) .ClientSideEvents(eve => { eve.ActionBegin("GridActionBegin"); eve.Create("GridCreate");
})
in my form I have this inbut box and button
<input type="button" value="Applica sconto" class="btn btn-default" onclick="applicaSconto()" /> @Html.EJ().PercentageTextbox("scontoGlobal").Value("10").MinValue(1).MaxValue(100).Width("100%")
this is my scripts
function GridCreate() { gridDetailObj=this; }
function applicaSconto() { $.map(gridDetailObj.model.dataSource.dataSource.json, function(elementOfArray, indexInArray) { gridDetailObj.updateRecord("ID", { ID: elementOfArray.ID, sconto: $('#scontoGlobal').val() }); }); }
this works fine on the displayed page, but if i have more than 10 item and change the page, in the others page the "sconto" value is not changed .
But in debug , in dataSource inspect i found all the records.
Q2.
The property of PercentageTextBox IncrementStep , not accepts double values.
This ERROR appear: Uncaught setModel - Invalid input for property :incrementStep - Expected type - number
This ERROR appear: Uncaught setModel - Invalid input for property :incrementStep - Expected type - number
@Html.EJ().PercentageTextbox("scontoGlobal").Value("10").IncrementStep(0.5).Locale("it-IT").MinValue(1).MaxValue(100).Width("100%")
My syncfusion version is 15.3.0.33
SIGN IN To post a reply.
5 Replies
SS
Seeni Sakthi Kumar Seeni Raj
Syncfusion Team
November 7, 2017 12:12 PM UTC
Hi Nicola,
Query #1: Grid not updating the Records in other pages.
We could see you would like to update the records in the other pages also using the updateRecord method. But you have bound a Grid with the local data. So, Grid will not aware of the other page records. Moreover, Grid will also update only the records from the current view page only. If you would like to update the Grid content from the other pages, you have to rebind the Grid dataSource once after finishing the records updates. This can be achieved using the dataSource method of the Grid. Refer to the following code example.
|
public ActionResult data() {
List<Orders> dat = order.ToList();
return Json(new { result = dat });
}
<script type="text/javascript"> $.ajax({
url: "/Home/data",
type: "POST",
success: function (data) {
$("#GridDetailPromo").ejGrid("dataSource", ej.DataManager({
json: data.result,
adaptor: "remoteSaveAdaptor"
}));
}
});
}
</script> |
Refer to the following API Reference.
Query #2:
We have checked your provided code block and reported the issue (“IncrementStep not support double value”) at our end. But unfortunately, we are unable to reproduce the problem at our end. We have prepared a simple sample to show case your scenarios (“Initial and dynamically change the IncrementStep Property”). Please check the sample in below location.
If the problem persists, please reproduce the issue in provided sample and revert.
Regards,
Seeni Sakthi Kumar S.
NI
Nicola
November 7, 2017 05:04 PM UTC
Thanks for reply
Q1
I don't update the local data, i read the local data just the first time. So this is my script and works
function applicaSconto() { var jsonDS=gridDetailObj.model.dataSource.dataSource.json; $.map(jsonDS, function(elementOfArray, indexInArray) { elementOfArray.sconto=$('#scontoGlobal').val(); }); gridDetailObj.model.dataSource.dataSource.json=jsonDS; refreshGrid(); }
Q2
Your sample works fine with UnobtrusiveJavaScriptEnabled=false, but i need UnobtrusiveJavaScriptEnabled=true and with this settings , your sample fails
with error:
"Uncaught setModel - Invalid input for property :incrementStep - Expected type - number"
SS
Seeni Sakthi Kumar Seeni Raj
Syncfusion Team
November 8, 2017 12:21 PM UTC
Hi Nicola,
Query #1: Relates to the Grid
In our previous update, we asked to the rebind the datasource for the Grid. Since you are using the local data, the Grid will not update the records of other pages, even if they are updated in the server-end. So, we suggested to retrieve the data from the server-end and bind them back to the Grid.
Query #2: Relates to the PercentageTextbox
We have checked this (“IncrementStep not supported in double value”) issue in unobtrusive mode, but still we are unable to reproduce the issue at our end. Please check the below image for Percentage Textbox with unobtrusive mode.
So, could you please reproduce the issue at our provided sample and revert. This would be more helpful to provide the solution at earliest.
Regards,
Seeni Sakthi Kumar S.
NI
Nicola
November 8, 2017 04:34 PM UTC
I downloaded , compiling and execute your sample without changing anything, with chrome and with Edge, this is the result.
I use Visual Studio Comunity 2015
SS
Seeni Sakthi Kumar Seeni Raj
Syncfusion Team
November 9, 2017 06:10 AM UTC
Hi Nicola,
We have created a new support incident for the PercentageTextBox related query. Visit the direct-trac page and login to your account. Please track the incident for further follow-up.
Regards,
Seeni Sakthi Kumar S.
SIGN IN To post a reply.
- 5 Replies
- 2 Participants
-
NI Nicola
- Nov 2, 2017 06:08 PM UTC
- Nov 9, 2017 06:10 AM UTC