Hi Team,
I am strucked with some error. Can you give some insight into the problem if where I am going wrong?
I have a Webdatagrid with RowAdding Behavior Enabled. The first column is a dropdown provider where in I can select a list of values.
Scenario 1: I am able to add a new row when clicking the row and pressing enter. When any cell is edited, I am setting the values to their defaults.
This scenario works fine if I dont change the value in the dropdown and the enter is pressed.
Scenario 2: But when I edit the dropdowneditor cell and change the value to a different one and press enter to add the row. I get the following error
Async request failed.
[Argument Exception]Invalid JSON Primitive |0|2222&tilda;8||
at system.web.script.serialization.javascriptobjectdeserializer.basicdeserialize(..)
.....
Can you please help me resolving the issue.
Regards,
Sudharshan.
Hello Sudharshan,
Thank you for posting in our forum.
How do you set the value of the cell to a default one? Do you use the DefaultValueAsString property for the RowAddingColumnSetting or do you set that value manually in js?
Do you add any special characters in the cell like &,% ,$ or something else?
Also could you let me know exactly which version of our controls you’re currently using and which service release version?
I’m looking forward to your reply.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://es.infragistics.com/support
Hi Maya,
Thanks for replying.
I am using Infragistics35.Web.v11.2, Version=11.2.20112.2159.
The values are set in javascript as soon as I click any cell in the AddNewRow present at the bottom using RowAdding_EnteringEditMode event.
And the values doesnot contain any special characters. It is a string containing years to select from the dropdown.
The logic here follows to set the year dropdown to next year which is not already chosen.
function grdCreditUtilRt_RowAdding_EnteringEditMode(sender, eventArgs) { var row = eventArgs.getCell().get_row(); if (row.get_cell(0).get_text() == "") { var years = document.getElementById("hiddenVar").value.split(";"); //hiddenVar='1999;2000;2001;2002;' var year = igcmbo_getComboById("comboId").displayValue; for (i = 1; i < years.length; i++) { if (document.getElementById("hiddenYears").value.indexOf(years[i]) == -1) { //hiddenyears = '2000;2002;' These are already chosen years. row.get_cell(0).set_text(years[i].toString()); row.get_cell(0).set_value(years[i]); break; } } if (i == years.length) { alert("custom message"); eventArgs.set_cancel(true); } } row.get_cell(3).set_text("A"); if (row.get_cell(1).get_text() == "") row.get_cell(1).set_text("0"); if (row.get_cell(2).get_text() == "") row.get_cell(2).set_text("0"); if (row.get_cell(4).get_text() == "") row.get_cell(4).set_value(parseInt($find('grid').get_rows().get_length())+1); // This is the row count, which is set to DataKeyFields }
Generally if you’re using a data table as the data source you could get the modified rows in the DataViewRowState of the DefaultDataView of the data table. You can then filter that the RowStateFilter by the DataViewRowState. There’s more on this here:
http://msdn.microsoft.com/en-us/library/system.data.dataviewrowstate.aspx
Generally you need to have a DataKeyField set to use any of the CRUD operations. You generally need to have a column in your data source that will act as a primary key. You should set it to be the DataKeField of the grid by setting the DataKeyFields property of the grid to the DataField name of the Primary key column.
If you want you can fill the new row’s primary key value on the server side before the data is actually commited to the grid on the RowAdding event. In the event args you’ll have the value that have been passed from the client but it’s not necessary to have all of them or update all of them to the new row that you’ll add to the data source.
Let me know if you have any questions or concerns.
I have a simple requirement to allow the user to add a row to the grid. I am using the Row Adding Behavior of the WebDataGrid
Do I need to set the DataKeyFields Property to the primary key of the datasource, which is the identity column too in my case.
Also my webdatagrid is build in the Business Logic layer.
I would like to update all the rows together added or edited or deleted. For which I enabled BatchUpdate="true".
When I add the row into the grid, how to set the primary key column value in RowAdding_EnteringEditMode.
I would like to know if there is any possibility that I can use the Row Adding Behavior without setting the DataKeyFields Property by manually looping the rows , in that way I want to just insert the data which I populated into the grid without bothering about the primary key column field.
Thanks for the Sample. My requirement got changed to ineditable cell rather than a dropdown. I need not look into the issue as of now.
I need assistance in getting the information of the row if it is edited or newly added or deleted if any.
I am using following Lines to know if the grid row is edited or added. Is this correct way to do that. I am using these lines of code in Button_click event.
bool isRowEdited=((System.Data.DataRowView)(((Infragistics.Web.UI.GridControls.ControlDataRecord)(grid.Rows[i])).DataItem)).IsEdit;
bool isRowAdded=((System.Data.DataRowView)(((Infragistics.Web.UI.GridControls.ControlDataRecord)(grid.Rows[i])).DataItem)).IsNew;
If these are correct. Then how to get the rows which are deleted.
I’ve tested this scenario on my side with the same version you’re using but was unable to reproduce this on my side.
Please refer to the attached sample and let me know if I’m missing something from your scenario. If possible please modify the sample so that it will reproduce the issue or provide your own sample that produces the issue.
Hi,
I am facing the issue yet. Can anyone help me in resolving the issue.
The following error occurs when a Webdropdown option present in the cell is changed for the first time and row is added to the grid and when a postback occurs the following exception occurs.
The exception wont occur if we add the row with the default values set in the rowentering javascript event and code dont break anywhere after that.
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: Invalid JSON primitive: |0|2007&tilda;37||.Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentException: Invalid JSON primitive: |0|2007&tilda;37||.] System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer) +542442 System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit) +37 System.Web.Script.Serialization.JavaScriptSerializer.DeserializeObject(String input) +13 Infragistics.Web.UI.Framework.RunBot.HandleOnInit(HttpContext context) +975 Infragistics.Web.UI.Framework.Data.FlatDataBoundControl.OnInit(EventArgs e) +161 Infragistics.Web.UI.ListControls.ListControl.OnInit(EventArgs e) +36 Infragistics.Web.UI.ListControls.WebDropDown.OnInit(EventArgs e) +37 System.Web.UI.Control.InitRecursive(Control namingContainer) +333 System.Web.UI.Control.AddedControl(Control control, Int32 index) +198 System.Web.UI.ControlCollection.Add(Control child) +80 Infragistics.Web.UI.GridControls.WebDataGrid.ConnectEditorProviders() +199 Infragistics.Web.UI.GridControls.WebDataGrid.CreateChildControls() +30 System.Web.UI.Control.EnsureChildControls() +87 Infragistics.Web.UI.GridControls.WebDataGrid.EnsureChildControls() +117 System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +23 System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +327 System.Web.UI.Page.FindControl(String id) +38 System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +626 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1743
Please Help in solving the issue.