Nested Data grid using ASP.Net 1.1 controls - c#

Has anyone worked on creating the Nested Data grids in ASP.Net 1.1?
Outer Grid: I would like to have the rows to be expandable. On click of "+" on each row, I would like the inner data grid to be populated with certain values based on that row.
Also export to excel feature for all of them in the same format.
I'm getting it using jQuery but looking for possible options in ASP.Net 1.1 controls itself.

If you're asking "How can I do this using just ASP.NET 1.1?" the answer is simple: you can't. Nothing remotely like that is built into ASP.NET 1.1, except perhaps in third-party controls (but good luck finding the 1.1 versions at this point.)
On the bright side, however, you won't have to deal with Microsoft Ajax features in 1.1, which means that the page model is more straightforward.
If your jQuery solution is working for you, there's not a strong case to be made for going farther. But if you want something more of a black box, that's reusable and automatically injects the jQuery code, you could subclass the DataGrid and write code to emit javascript code blocks containing your jQuery code.

Related

ASP.NET Dynamic Data GridView Control Replacement / Substitution

Is there an easy way to replace / substitute the standard Microsoft ASP.NET GridView control in a Dynamic Data EF project? I know there are plenty of component vendors that ship GridView control with out of the box functions that go way beyond what the default ASP.NET GridView provide.
Considering this project is using the following: Standard ASP.NET C# 4.0 Dynamic-Data EF website project (VS 2010).
Specifically, here would be my requirements:
The main purpose is to swap the current ASP.NET GridView control
with a more powerful one (see specific requirements for the GridView
below).
Easy migration of the project (not too much code to re-write
to substitute the grid).
Gridview specific features:
Support for freezing header-rows and ability to pin specific columns.
Inline editing (granted, the standard GridView control supports it already).
Excel like column filtering (i.e. multiple choices based on column values).
Column re-ordering.
Out of the box group-by capabilities.
Have you ever been through such a substitution exercise?
If you have I would appreciate your feedback!
Thanks, Ben
I know there are a few who support Dynamic Data like Wijmo grid and Telerik grids but I've not tried the most recent version for compatibility. Telerik may be you best bet I would ask on their forums.

How to implement client side sorting on an asp.net gridview having server side paging?

I am using asp.net gridview throughout my application but have got new requirement to apply sorting on each column in almost every gridview in the application. Many of the gridviews consist server side paging. I tried jquery tablesorter plugin for client side sorting and it is working fine, should it work fine with server side paged grids as i think it should be able to sort only current page records (not all the records). If yes then how?
In past experience, I've had a lot of trouble using out of the box Microsoft tools with jQuery, especially jQuery plugins. Not saying it's impossible, but my recommendation would be to either ditch the out of the box microsoft tools, or use the sorting that comes with them displayed here: http://msdn.microsoft.com/en-us/library/vstudio/hwf94875(v=vs.100).aspx

Is there a ready-made data table view library with paging/filtering/sorting?

I'm building a system in MVC that has a lot of heterogeneous data to be displayed: Customers, logs, etc.
I'm finding that I'm building the same view over and over again in different forms:
Header row (with sorting links)
Filter row (drop-downs, date pickers, etc.)
Data
Paging row
Naturally the abstractor in me is shouting "Build a generic data view factory!", as well it should. However, before I disappear up my own abstracting bottom, has this work already been done elsewhere?
The only option I can currently find is MVCContrib.Grid, which doesn't seem to handle the rendering of filters (although it has allowances for extending the renderer). Is this the only option?
As one may expect a question similar to your has already been done...years ago. So here: grid controls for ASP.NET MVC? you can find a list available data grids, that has been updated in the years. I recommend that you, once and for all, give a look to all of them, so in the furure you may choose the more adequate to your needs. There is no better grid, but each of them has advantages and disadvantages.
Yes, I could recommend this jQuery plugin
http://datatables.net/
My Choice would be between
datatables.net (Already mentioned)
jqGrid (http://www.trirand.net/demoaspnetmvc.aspx)
I've foud the datatables easier to use at first, but finally I've used jqGrid as I've foud it more powerfull.
I've used both KendoUI and jqGrid successfully. jqGrid is a light-weight and less expensive solution if all you are looking for is a grid. One of the things I liked about jqGrid aside from its easy integration with knockout was it's ability to edit data in table cells as well as creating a "edit view" in which the data is edited in a form-type view with labels beside edit widgets.
That said, it sounds like you might be looking for more than a grid, and if so you should also look at using Html helpers to generate the constituant parts (header w/filter, data rows, paging, etc). This would give you ultimate flexibility over where the different parts are rendered on the page. Maybe you want to put the paging controls twice on the page at the top and bottom; maybe you want to put the filtering into a modal dialog box. The ability to simply go:
#Html.FilterControlsFor(Model.PhoneBookUsers)
someplace (or someplaces) on a page and have the helper deal with all of the details is pretty powerful juju.
Flexigrid - nice table plugin, but it is only ui table you should provide appropriative server side processing for selection and filtering data.
KendoUI any day. Theres a ASP.NET wrapper but it's quite expensive. But the jQuery lib is definitly the best out there.

Manipulating a webpage by its source

I have googled this with a couple of differing terms and I could not find my solution. What I want to do is to manipulate a webpage by editing its source, for example removing a part from the code maybe a div or so. I know how to get the source of a webpage and know how to change the code but I have no idea how to manipulate the page instantly, by for example removing an element.
Your help would be appreciated!
If you want to manipulate client code (HTML) what you need is Ajax.
You can use JQuery javascript library to manipulate html of a page adding, editing and removing html tags, scripts, etc.
Here you can find a decent tutorial as a start point.
If you want to manipulate server code (C# codebehind) what you need is creating a web project in visual studio (ASP.NET Web Application)
EDIT: As commented by #CSharpened both solutions are not mutual exclusive. You can have an ASP.NET Web application that uses Ajax to manipulate UI. In fact lot of people does that.
I would consider using AJAX. You can use either javascript or jquery coupled with html, asp.net and C# to achieve the results you are after.
For simple editing like removing divs or collapsing menus etc simple Javascript or jquery will suffice. However changing the coding of the page requires you to use AJAX or similar.

Using JavaScript template with ASP.NET

I ran into this problem multiple times in my career, and never was able to find a elegant solution for it. Imagine you have a simple page, that has a repeater. You populate that repeater on the server-side through the databinding. That's great, works fast and does what it's supposed to. But now you want to add paginator to that repeater, or otherwise change the output. Doing it through Ajax is a preferred way to enable rich client interaction.
So you create a web-service that serves you the data as JSON, but now you are stuck... Either you have to write complicated client-side code to find each field that you need to modify in each repeater-item, or you have to blow away the whole server-side output of the repeater and construct new HTML from the scratch, or, the method that I've been using lately, take the first repeated item, blow away everything else and clone the first item as many time as you need to and modify it's fields.
All of the described methods are not optimal, because no matter what, they require quite a bit of repeated logic on the server-side (i.e. template in repeater) and on the client-side (javascript to display JSON data). There's got to be a better, easier way to do this. First thing that comes to mind, is instead of returning JSON from the web-server, return HTML of the pre-populated repeater. But for something like that, I might as well use ASP.NET AJAX Update panel. The output isn't going to be any smaller with a stand-alone web-service.
Next thing that I thought of, is JavaScript templates. What if there would be some way to take unprocessed repeater template on the server-side, and convert it to JavaScript template that could be either embedded on the page at load, or served as part of the web-service response. However, I couldn't find any existing solutions for something like this. And I can't think of a simple way to do that myself. Any ideas?
P.S. Rendering JavaScript template to the client-side on page load, and using JavaScript to populate it without the initial view being rendered on the server (no repeater and databinding) is out of the question. I care too much about performance.
Firstly, I don't believe that using client template with JSON data even on first load will adversely affect the performance unless we are talking about devices with different form factors such as phones etc.
However, if you must use server side templating/rendering then why not make server return the html for the repeater. This can be done by putting repeater logic into a different user control/page and processing only that page on ajax request. And this is not at all equivalent to using UpdatePanel (as stated by you) - UpdatePanel posts entire page data (including view-state) having more request size. The response size is also larges because it must contain the view-state. On server side also, use of UpdatePanel results in loading complete control tree with state data and post-back event processing. Sending only the requisite html is much better approach and will fit your needs perfectly - only issue is the html would be larger in size as compared to JSON.
Lastly, there are some interesting projects such as Script# - Script# converts C# code into java-script. You may build something similar (using script# itself) to convert the server side templating code into eqivalent JS code. More viable approach on similar lines could be use T4 templating to convert a technology-agnostic template into both server side code (markup + code or pure code) and equivalent JS-code.
After thinking about all pros and cons of different approaches, I stopped on the following method. I created a custom ASP.NET databound control, that can render HTML, however, when the page is requested with query string parameters, instead of just doing standard rendering, it will use Response.Clear() and Response.End() and in between of those two commands output JSON version of data based on the query string parameters. Also on the first rendering of the page, it will also output JavaScript template using reflections to read names of the variables from the control's template area.
This method works great, all I have to do, is drop my control on the page, data bind it, and it works as a true AJAX grid that supports pagination, sorting and filtering. However it does have limitation. In the control's template you can only specify variables, not expressions. Otherwise reflections can't convert it to a JavaScript variable. But I can live with that.
Other possibilities that I considered is a separate web-service that takes a type of the page as parameter and uses reflection to get data bound object as well as create template for the grid. I also though about writting my own version of update panel, that would not use view state and only send in part of the page.

Categories

Resources