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

Handling server errors for ajax bound listview

3 Answers 79 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 08 Sep 2012, 05:39 PM
I have a listview that is bound to an MVC controller, the view populates fine and pages fine, I would like to enable adding a new listview item so I added a template with a single textbox bound to an autocomplete that also populates from the server. All that works fine, but when I invoke the add on the listview, it is immediatly added to the listview and then the call appears in the controller. If the add executes then all is fine, if not then it is out of sync and there is no way to indicate to the listview to refresh or that an error occured. I have tried returning errors in the  same way a Grid expects them (JSON object with Data, Errors and Total), I have tried simply returning a 500 error, but I cant get seem to figure out how to indicate that the operation failed.

Attached are the razor view, the editor temmplate and the controller.

Thanks in advance for any advice


3 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 13 Sep 2012, 01:17 PM
Hello Robert,

Unfortunately the information is not sufficient to get more complete understanding  on your scenario. Can you provide us with runnable sample so we can assist you further?

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
Robert
Top achievements
Rank 1
answered on 13 Sep 2012, 06:34 PM
I can build out a sample if you want to see the specifics, but I have accomodated the issue by callling the dataSource.Read() on the listview in the error handler for the dataSource. Is seems a bit inelegant in that the item first appers on the list, and then we get the error back from the server and the entire listview needs to be rebuilt. Ideally we could have some type of completion processor before the item is added.
0
Nikolay Rusev
Telerik team
answered on 18 Sep 2012, 02:58 PM
Hello Robert,

Adding item in the DataSource will cause the DataSource to trigger its change event which will result in updating ListView items. This is the behavior that will be observed in every data bound widget.

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!
Tags
ListView
Asked by
Robert
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Robert
Top achievements
Rank 1
Share this question
or