Telerik MVC Grid sever binding with ajax editing - ajax

I have an application that is making extensive use of telerik controls and am looking for an example/demo of Telerik MVC grid that uses server binding to display the initial grid and then allow inline editing using ajax. I have a selection that is returning a lot of data and erroring out at the maxJsonLength. The code to configure the grid would be helpful and I should be able to fiigure out the rest. I think I saw an example somewhere of an ajax bound grid that used server binding for the initial load but I can't find it.

Having a server-side bound grid with ajax editing is possible. However you first need to solve the maxJsonLength problem. The grid needs to serialize the first page of data (which is initially displayed server-side) as JSON so it can be then edited on the client-side. It seems that you are serializing too much data which hits the maxJsonLength limit. I can think of two ways to deal with this:
Use a ViewModel and serialize only the properties which are bound to the grid. This will reduce the total JSON size.
Increase the maxJsonLength. This however is not easy as setting it from web.config does not work in ASP.NET MVC. You need to create a custom JsonResult object with its own JsonSerializer. This code library project shows how.

You have mentioned Telerik in your title but not in main question, so I assume that you are okay with other grid controls.
In that case you can try Jq grid, it's very flexible and easy to use. I have been using it for some time now and find it very useful.
For your particular case see below link
http://www.trirand.com/blog/jqgrid/jqgrid.html

Related

Kendo MVC: editable grid with local data

I want to create editable Kendo MVC grid bound to local data(some IEnumerable<>).
I found this and this. But first is only for js and second is not ediatable.
Is it possible?
I have tried all modes of Editable. But Editable() requires to specify related actions and it's impossible to prevent its execution.
As far as I know, editing is not supported with server side binding. In the past, I have used a Template column with links to edit the items. An example:
cols.Template(#<text>Edit</text>)

How to Handle Mutiple Model Bound Forms

I am buiding a UI screen for editing the details of an Ecommerce Order. The model for my view (OrderModel) has everything I need (in properties that are also ViewModels), but the UI isn't designed to be able to edit all of it at once.
For example, one part of the UI is for customer data..another for order details, and another for tracking information, each having their own "Save" buttons.
I realize that I could use one giant form and use hidden form fields to populate the non-editable fields, making each "Save" button post all the data, but that smells bad.
I'd like to segment the editable chunks into smaller ViewModels that are posted and validated individually while retaining the strong typing but I'm unsure of how to achieve this in MVC3. Will I need partial views that are called from the primary view?
FYI, I'm using ASP.NET MVC 3 with Razor syntax and client side FluentValidation.
Partial Views are a good solution. You can pass different ViewModels to each partial view. But if only sections of the overall view are updated at a time I would not do a post back on the whole page. Instead I would use Ajax calls using JQuery/Javascript to update the individual information back to the controller. I would also look into something like Knockout.js to handle the data binding on the page.

Getting a value from an MVC 3 Razor RadioButton list

I'm coming from a WebForms environment. When I wanted values from a radiobutton, the form simply got ajax reposted or I got it thru javascript.
I've searched the web, but can't seem to find an equivalent for MVC 3 Razor.
I'm not posting the form, so I can't use the FormCollection object in the ActionResult.
I simply want to get the value of which option in the RadioButton is checked when a user checks one of them.
I assume I would do this thru an Action method in a Controller once a user checks one of the values.
Note also, that this radiobutton list is in a partial view and is available to the entire website (because it is in my _Layout.cshtml view).
Can someone please help me out with what I think should be a simple task?
You need to use javascript. See this post. MVC does not have the concept of an Auto-Postback like in Webforms. This is an optimization in the page loading time (no self-managed viewstate). This means you need to manage the statefulness of controls yourself.
In short, if you're not posting (or "getting") the form then the value won't be available in the controller...more specifically, neither the controller nor it's actions will be called at all.
If you're trying to do something strictly UI related, then you may want to consider jQuery.
If you're trying to do some sort of model validation inside of the view, you may want to reconsider your approach and usage of the MVC pattern.

Retrieve value posted from MVC3 aspx view

views are different from web forms? I can't seem to access my server controls on the view.
With a webform you can retrive the value of a textbox as <name>.Text as long as it's a server control. How am I supposed to do this in MVC3? I'm using aspx views.
I know the value is in the Request.forms collection but isn't there a less ugly way to retrive the value of a textbox.
I assume you mean accessing the values in the action, not in the view.
There are several ways, one is by accepting them as parameters of your action method (model binding; another sample), the other is manually read Request.Form as you suggested.
But this is a very short answer. You must learn MVC basics before you try to dive into the water and code. In MVC, the chance that you'd do the wrong thing (against MVC's architecture) is very high if you don't learn the theoretical stuff before.

Efficient gridview in asp.net webforms

Hy guys.
As you know the gridview control is super heavy and reduces performance of the page, as the viewstate length is higher.
I'm trying to get a alternative way to not use default asp.net gridview webforms.
In asp.net mvc we can pass a model for example with Examples[] and in the view iterate over this array and build a
grid and using a number of pages as a anchors than when clicked do a request to a one controller and retrieves json with content of the next 10 tuples in database.
My question is, what is for you guys the best way/more efficient to implement a gridview with paging in webforms?
We use classic AJAX calls and javascript to render and filling the gridVeiew. We are also using the jQuery gridviews now. I am aiming at the reduction of data transfered if we are using a asp:gridview inside a ajax:updatePanel.
Unless you plan to use the fill GridView functionality, I usually prefer rendering the UI out as HTML TABLE using a asp:Repeater control.
HTH.

Resources