jQWidgets Forums
jQuery UI Widgets › Forums › ASP .NET MVC › asp.net tag helper grid in edit mode with dropdownlist
Tagged: ASP.NET tag helpers, jqwidgets, mvc core
This topic contains 6 replies, has 4 voices, and was last updated by Peter Stoev 8 years, 4 months ago.
-
Author
-
I´ve got this grid developed with tag helper:
<jqx-grid id="grid" auto-row-height="true" auto-height="true" source-id-for="@listaResiduos.IdtipoResiduo" filterable="true" instance="gridInstance()" auto-show-filter-icon="true" theme="energyblue" edit-mode="selectedcell" editable="true" create="@Url.Action("Add","TipoResiduo")" delete="@Url.Action("Delete","TipoResiduo")" edit="@Url.Action("Edit","TipoResiduo")" pageable="true" page-size="10" sortable="true" width="100%" source="Model.listaTipoResiduo"> <jqx-grid-columns> <jqx-grid-column datafield-for="@listaResiduos.IdtipoResiduo" editable="false" pinned="true" text="Identificador"></jqx-grid-column> <jqx-grid-column datafield-for="@listaResiduos.DestipoResiduo" text="Descripción"></jqx-grid-column> <jqx-grid-column datafield-for="@listaResiduos.IdgrupoResiduo" column-type="dropdownlist" text="Grupo de residuo"></jqx-grid-column> </jqx-grid-columns> </jqx-grid>
When i set the column-type=”dropdownlist” if i try to edit that column the data sent to the server in json format has not the correct id. In my case the id is source-id-for=”@listaResiduos.IdtipoResiduo” and when i edit the dropdown it sends the row number not the field value.
For example when i edit the first row i receive this in the server side:
{"IdtipoResiduo":0,"DestipoResiduo":"sdsg s s gsgs gsg aaa","IdgrupoResiduo":"Albania","uid":0,"boundindex":0,"uniqueid":"3126-19-29-24-272330","visibleindex":0,"_UID":0}
As you can see my id field IdtipoResiduo is 0.
If i edit the next row:
{"IdtipoResiduo":1,"DestipoResiduo":"sdsg s s gsgs gsg aaa","IdgrupoResiduo":"Algeria","uid":1,"boundindex":1,"uniqueid":"2724-23-28-19-211630","visibleindex":1,"_UID":1}
As you can see the IdtipoResiduo has the value 1. Again the row number.
Any help?
Hi rubenfernande3,
The DropDownList does not know about your Grid source.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comI try to explain again. My grid has a column With type dropdownlist. I open de dropdownlist in edit mode i change The value and in That moment The server receives The data With The id of The grid With Row value instead The grid key. So the edit doesnt works because it doesnt find the correct key for updating the object.
In other Words The edition in a grid of a column type dropdownlist doesnt works when i use tag helpers.
Hi rubenfernande3,
As far as I see IdtipoResiduo value is 0 or 1. What is it in the data source?
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThe grid is composed by 3 columns:
-IdtipoResiduo.
-DestipoResiduo.
-IdgrupoResiduoIdtipoResiduo is the key of the grid (source-id-for=”@listaResiduos.IdtipoResiduo”). This means that when i try and update the aplication has to send to the server the value of IdtipoResiduo to perform correctly the edit action.
When i update the column DestipoResiduo (this column is a text column) it Works perfectly.
When i update the column IdgrupoResiduo (this column is a dropdowlist column–> column-type=”dropdownlist”) it doesnt work. The IdtipoResiduo has a wrong value. Instead of sending the value of the column IdtipoResiduo it sends the value of the row number.To see better the error i generate another test. This time i have in my grid 3 rows.
If i update the column DestipoResiduo with another value i receive this in the server:{"IdtipoResiduo":"3452","DestipoResiduo":"description tururu","IdgrupoResiduo":"444","uid":"3452","boundindex":2,"uniqueid":"2225-18-28-28-243021","visibleindex":2,"_UID":"3452"}
As you can see now IdtipoResiduo has a 3452 value. This is the correct value and this Works perfectly.
Now i try to update the dropdownlist column (IdgrupoResiduo). I receive this in the server side:
{“IdtipoResiduo”:2,”DestipoResiduo”:”description tururu”,”IdgrupoResiduo”:”grupo residuo 3″,”uid”:2,”boundindex”:2,”uniqueid”:”2225-18-28-28-243021″,”visibleindex”:2,”_UID”:2}
Now IdtipoResiduo has a value 2. This is because im editing the 3 row. Instead of sending 3452 value it sends the row number. Is strange because the value of the dropdowlist is correct. It only fails with the id of the grid.
I confirm also this BUG all columns inside JSON data has wrong value, ID, UID, _UID.
Maybe work around is to have in model one more ID column for referencing updates.For now, you can consider that the Row’s ID and Row’s Index are equal in the ASP .NET MVC Grid.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.