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

Sending Grid DataItem to Modal using URL

7 Answers 95 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Scott Marx
Top achievements
Rank 1
Scott Marx asked on 09 Aug 2013, 05:26 PM
Here is my function to open the window, but I am get the following error;

Cannot read property 'field' of undefined

How do I use the data items on the loaded page?

function showEdit(e) {
e.preventDefault();
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
editWindow.refresh({url:"/Managers/ratesheet_edit.aspx",data: dataItem});
$("#editRateSheet").closest(".k-window").css({
top: 10,
left: 10
});
editWindow.open();
}

7 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 13 Aug 2013, 08:59 AM
Hi Scott,

Generally speaking your code looks OK. I am not sure where exactly the problem comes from.
Could you please confirm that the reference to the dataItem is retrieved correctly?
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
console.log(dataItem); //is dataItem defined?
editWindow.refresh({url:"/Managers/ratesheet_edit.aspx",data: dataItem});

As an assumption, you may try to transform the observable object into standard one before passing it to the server.

editWindow.refresh({url:"/Managers/ratesheet_edit.aspx",data: dataItem.toJSON()});

In case this does not help, I would like to ask you to send me a small but runnable sample which isolates the issue. In this way I will be able to examine your case in details and assist you further.
Thank you in advance.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Scott Marx
Top achievements
Rank 1
answered on 15 Aug 2013, 04:43 AM
The console log show the dataItem. When I try to set the field value it just displays #=data.Description# as the value.
0
Alexander Valchev
Telerik team
answered on 15 Aug 2013, 03:46 PM
Hi Scott,

The provided information seems to be incomplete. Where #=data.Description# comes from? Is it part of a template? Where it is used? When and how you set the field value?

Could you please prepare a small but runnable sample which isolates the issue? In this way I will be able to examine your current implementation in details and assist you further.
Thank you in advance.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Scott Marx
Top achievements
Rank 1
answered on 16 Aug 2013, 04:01 PM
I created a test and attached it. You may have to add in the js and css files.

Basically I am trying to load the values of the data on to another page for editing.

Scott
0
Alexander Valchev
Telerik team
answered on 20 Aug 2013, 02:43 PM
Hi Scott,

I was not able to reproduce the error with the provided test page. Does the issue occurs in a specific browser only (I tested on Google Chrome and IE 10)?

On a side note, I would recommend using the MVVM approach to edit Grid data. There is a code library which demonstrates editing in external container which might be in help.
The general idea is that the dataItem is bound to the editor form via Kendo MVVM. In this way the DataSource is able to keep track of the user changes and synchronize them with the server.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Scott Marx
Top achievements
Rank 1
answered on 21 Aug 2013, 11:23 PM
It's not that there is an error... How do I access the data items?

The only way I was able to access them is by doing <%=request.QueryString("dataitem")%>, is this the only way?
0
Alexander Valchev
Telerik team
answered on 23 Aug 2013, 02:22 PM
Hello Scott,

I am afraid that using the template syntax (#=data.Description#) inside testing.aspx page is not supported. In your case the content is not a template.

If you would like to use a template, please follow the approach demonstrated in the following code snippets.

Or stick with the solution that you found, e.g. <%=request.QueryString("dataitem")%> syntax.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Scott Marx
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Scott Marx
Top achievements
Rank 1
Share this question
or