This is a migrated thread and some comments may be shown as answers.

Would like send the data-uid to server

4 Answers 392 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Damir
Top achievements
Rank 1
Damir asked on 20 Mar 2012, 06:29 PM
Hi,

I would like send the UID from a new entry with the other data to the server. (I use the beta from KendoUI)

schema:
schema: {
                               model: {
                                   id: "ID",
                                   fields: {
                                       Email: { validation: { required: true}},
                                       datauid: { editable: false}
                                   }
                               },
                               total: function(result) {
                                   // Count records
                                   //alert(result.length);
                                   GridCount_dataBound(result);
                               }
                           }

columns:
columns: [
                            { field: "Email", title: "<?php echo $this->translate("Email"); ?>"},
                            { field: "datauid", title: "<?php echo $this->translate("UID"); ?>",  template: "<input type='hidden' name='datauid' value='#= uid #'>"},
                            { command: [
                                        {name: "edit"},
                                        {name: "destroy"}
                                       ], width: "200px"
                            }
                        ],

I can see the uid in the input field but the model is emty:
models  [{"ID":"","Email":"cyxcyxcxy","datauid":""}]

Could you help me?

Best regards
Damir

4 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 22 Mar 2012, 09:16 AM
Hello Damir,

Can you explain why you need to send the UID to the server? It's an id generated by the framework and it isn't part of the data.

Greetings,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Damir
Top achievements
Rank 1
answered on 22 Mar 2012, 10:27 AM
Hi, yes!

When I load the grid with the data from the database, you can see the following (it's an example) in the model:

models  [{"ID":"2","Email":"your@email.de","datauid":""}]

The ID is the unique ID from the database entry and I need the ID for updates an deletes - for each entry it is a other unique ID.

OK, following scenario: When I make a new entry in the grid and save the data, the ID is empty, because the ID comes from the database after insert in the database. When I try to update the data record directly after insert, the ID in the grid row is empty and my update on the server side failed! The grid would not be empty when I update the grid but that is not desired.

My idea is the following: The grid send the new data with the UID to the server. Return of the Grid as receive the new ID from the database and the UID. Now I can change the empty ID with the new unique ID from the database (and for this I need the UID to be found the record in the grid). Now I can change or delete the new row in the grid, because the ID is not empty. I need the UID only when I insert a new row!

Do you have an other idea????

And my next question, when i become the ID back with the UID, do you have an example how can I update the empty ID with the new ID?

Best regards
Damir
0
Nikolay Rusev
Telerik team
answered on 23 Mar 2012, 04:25 PM
Hello Damir,

First of all here are few complete examples of Grid CRUD operation:
https://github.com/telerik/kendo-examples-asp-net-mvc
https://github.com/telerik/kendo-examples-asp-net

Generally to send any data to the server you can provide your implementations of DataSource parameterMap option.

The ID field should be generated on the server and newly inserted item must be returned back to client, so the DataSource can update it's internal data and the Grid widget will update the column for this field.

You can see the examples above for more implementation details.

All the best,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Damir
Top achievements
Rank 1
answered on 23 Mar 2012, 05:12 PM
Hi Nikolay,

so easy..... :-) Thank you so much!!!!

Best regards
Damir
Tags
Grid
Asked by
Damir
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Damir
Top achievements
Rank 1
Share this question
or