I have a igGrid, but the type of data which are not represented.This occurs because the iggrid is updated and every time represents a different model.When I want to save changes to the model, I can not, because I is not the model type.To save the changes I have a function that I found in the documentation for Infragistics.Is the next function:
Public Function EditingSaveChanges() As ActionResult ViewData("GenerateCompactJSONResponse") = False Dim m As New GridModel() Dim transactions As List(Of Transaction(Of Object)) = m.LoadTransactions(Of Object)(HttpContext.Request.Form("ig_transactions")) For Each t As Transaction(Of Object) In transactions If t.type = "newrow" Then ElseIf t.type = "deleterow" Then ElseIf t.type = "row" Then Next Dim result As New JsonResult() Dim response As New Dictionary(Of String, Boolean)() response.Add("Success", True) result.Data = response
Return result End Function
This modified to receive anything, but I know the type of object that gets me.Any way to get the type of which is the object that gets me?when I do "t.row", I just say "object".
Thanks advances.
Best Regards.
Hello nitaGM ,
Thank you for posting in our forum.
You need to provide the type of the model when you load the transaction:
Dim transactions As List(Of Transaction(Of YourModel))
Otherwise the method will not be able to de-serialize the data the HttpContext.Request has returned((HttpContext.Request.Form("ig_transactions"))).
Basically from the client side you’re passed a string that looks something like this: "[{\"type\":\"row\",\"tid\":\"e35b\",\"row\":{\"ProductID\":1,\"Name\":\"5\",\"ListPrice\":10,\"Name\":\"somename\"},\"rowId\":1}]"
The client is of course not aware what model you have set for the grid so there’s no way to get that information from the request.
You could manually keep track of which model the grid is currently using so that you can de-serialize updating request accordingly with the LoadTransactions() method.
Or you could manually de-serialize that object for example:
List<Object> list = new JavaScriptSerializer().Deserialize<List<Object>>(HttpContext.Request.Form["ig_transactions"]);
Which will give you a list of the key/value pair which you can then use to update your data .
Let me know if you have any questions.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://ko.infragistics.com/support
Hi Maya,
In the end I did a Select Case in the driver for all cases that come.Thank you.Once I have this problem solved already, now comes another problem regarding this.But as I have defined the type of the table, I can not define it explicitly. This attempt to use reflection and not working.I do the following in the igGrid:columns (sub (c) c.For (sub (x) x.getType.getProperty ("MyProperty")). hidden (true)End sub)
But I get an error NullReferences.Could you help to delimit the fields I want to display without having defined the table?
Thanks in Advances,
Best Regards
This is just what I needed.Thanks Maya.
It has been a problem in relation to the question I asked.When I use what you told me, I put a hidden (true) the primary key.But doubling the primary key, and I have a hidden primary key, and another that looks.It makes sense that when I hide a primary key, a doubling and display.All we got was
.Columns(Sub(column) column.For(Function(x) x.GetType().GetProperty(Model.Id).Name).Hidden(True) End Sub)
Thanks in advance.
Hello nitaGM,
I’m not sure I understood your question.
Do you want to set two primary keys but have one of them hidden?
Could you elaborate on exactly what you’re doing and what is the issue you’ve come across?
I’m looking forward to your reply.
Developer Support Engineer II
The problem comes when I want the primary key is not seen on the table.I do not know, but when I say that the primary key is hidden, is still seen.In the view I have the following code:
@(Html.Infragistics().Grid(Model.listaGrid.AsQueryable).ID("grid1").PrimaryKey(Model.Id) _ .UpdateUrl(Url.Action("EditingSaveChanges")) _ .AutoGenerateColumns(True) _ .Features(Sub(features2) features2.Paging() features2.Selection.Mode(SelectionMode.Row).MultipleSelection(False) features2.Updating() _ .EnableAddRow(True).AddRowLabel("Añadir nueva fila") _ .EnableDeleteRow(True) _ .EditMode(GridEditMode.Row) End Sub) _ .Columns(Sub(column) column.For(Function(x) x.GetType().GetProperty(Model.Id).Name).Hidden(True) End Sub) _ .Height("90%").DataSourceUrl(Url.Action("PagingGetData")).DataBind().Render())
In this case, the primary key is ID_Pais.
finally this is what I see in the header is:
ID_Pais Codigo DEscripcion (And a cell white).
I can not send an image capture, but I hope I explained better now.
Thank you for the code snippet and clarification.
It seems that you autogenerate all the columns in the grid:
.AutoGenerateColumns(True) _
So the grid will create a column for each property in the model including one for the “Id” column.
If you set that to false and define the columns in the Columns collection you should get the expected result.
If you want the columns to be autogenerated but want to also hide that particular column you could use the Column Hiding feature:
https://www.igniteui.com/help/api/2019.1/ui.igGridHiding
Let me know if you have any questions or concerns.
www.infragistics.com/support
Thanks to what you told me, I understand what I needed.
I’m just following up to see if you’ve been able to resolve your issue. If you have any questions or concerns or if you need further assistance please let me know.
Do you mean you want to make a specific column ReadOnly?
Generally you can specify that in the Column settings under the Updating feature. For example:
features.Updating()
.ColumnSettings(settings =>
{
settings.ColumnSetting().ColumnKey("EmployeeID").ReadOnly(true);
…
There an example on this here:
http://ko.infragistics.com/products/jquery/sample/grid/editing-client-validation
The first column is set as ReadOnly.
Let me know if I understood your issue correctly.
Thank you very much for the clarification.
If I wanted to change the index that is used to initialize the primary key if this is readOnly, how could I?