JQGrid and asp.net - c#

In the past when I've used jqgrid all i have done is had a static web service and the grid loads as the page does. Now I need to have a form that i want to send values from to the service, and the results need to be in the grid.
I'm struggling with a couple of things -
How do i format the url function in the grid to send parameters with it, in the past i have got away with just url: 'JsonData.asmx/GetData
How do i actually call the update method of the grid from a button?
I'm writing the web app in c#, dotnet 4
Thanks
Luke

I see no problem in what you explain. If you could fill the grid data using url: 'JsonData.asmx/GetData' it should continue to work inside of the form. You should only verify the font size which you use in the form to have good look together with the grid.
If you need reload data in the grid you can use $("#grid_id").trigger('reloadGrid',[{page:1}]); (see here).
One other possible problem which you could have: one should create jqGrid once. If you for example need create the form once which contain one grid and later change the for contain to have another grid you could have to use GridUnload method. See here and the demo and here.

Related

List data in multiple views edit data on click

I'm trying to figure out what design object to use for my forms application.
I want to make a forms application that looks like below image.
I have so far used splitcontainers for the layout and three gridviews with separate DataSources querying the same table but with different where clause for eatch gridview. This works fine but when i click a row in any of the three gridviews i cant have that data show on the right side becaus i can only get data from one datasource on my labels and textfields etc.
I guess that i should use one datasource but in some way have different where clause to each gridview but i've tried it and i only end up with the same data in all of the gridviews.
If it's to complicated to get together i would instead have a new form window apeare with a click of a button. So if i select one row in any of the gridviews and then click edit a new forms window will open for me to edit data in. How can i do that?
Please advice me how i should try to build the application.
For example; Dont use gridviews use this or that instead. Dont use splitcontainers use this instad. Use bindingsources... etc.
I really appreciate any help you can provide

Passing a C# list with 100 DTO items to front side through Ajax Post

I am going to show a large data C# list at the front side page.
The current condition is a C# List consist by about 100 DTO items are unable to be sent to front side from back side. it will always showing error.
Then I change a way to display, the table is put in the another page, it is being a partial view being load in the index page, it always be load again when switch page.
I am using jquery Datatable, the issue is the div and table will always shows without css style about 0.1 second then turn into with style sheet(like a flash)
I trying to find the way to solve this issue but I am unable to find so far, actually i prefer to send a complete list to front side and use for each to show it, but now I can not solve the flash page niter the ajax error

General concept regarding dynamic textboxes on the fly

I am working on a project which has a requirement to build "pages" on the fly. A page can consist of various controls like textboxes, checkbox etc. Currently when the user wants to add a new textbox I make a ajax request and render partial view and return the HTML and show it on client side. This works but I also want to handle the data properly when these dynamic controls are filled up by user. In a way if I am not wrong I need to be able to make array of HTML controls. Now if we give static List to our view and generate textboxes using Html.TextboxFor we see that the name generated is something:
[0].FruitName
[1].FruitName
[2].FruitName
How do I handle this index part when making a Jquery Ajax request so that I always get the correct indexes and render it on client.
If anybody has any better solution than making ajax request then also please let me know. I need to handle the dynamic rendering of HTML controls and also access their values properly when posted back to server.
Take a look at Non-Sequential Indices at http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx.
He introduced a helper method to generate it as well.
Also, I think you can just pass an index with your ajax call which then gets passed from Controller to your partial view and use it to generate a proper indexed TextBox.
Update:
I've asked a very similar question at Submit javascript dynamically added elements to controller method like Stackoverflow

list view problem with respect to my problem

I have a listview in wpf and i am swapping two items index..
the swapping must be visible to the user.
i tried giving thread delay..
it didnt work
How to do that..
If I was going to do this I would delete the list view and lock it up where you can't use it again. Then code whatever your list view was outputting in C# using whatever you use to query your database(I think LINQ to SQL is the most robust solution right now) and then use a string builder to construct the html. This way you can assign a id to each div and append an incrementing number to the end of the id. Finally you could write your javascript and use the id's. Here is a link that shows how to build a gridview without using a gridview control.
See the first answer to the question in this link: How to show pop up menu from database in gridview on each gridview row items?
I am not sure whether it will work for your problem or not.
I think you need some kind of animation there. If it is web project, you can use jQuery animation to do that.

Simple MVC Question for MVC beginner

i have an Ajax ActionLink which normally just returns a PartialView (which is just a UserControl ascx file) however, my needs have changed and i want to return another PartialView (so a total of two PartialViews) that occupy different areas of my page... of course i can't call " return PartialView("UserControl.ascx") " twice in a row consecutivelly... so my question is what would be an elegant work around for this?
how can i return two PartialViews WITHOUT wrapping these two PartialViews up in a larger parent view? i hesitate to do this because both items are in a different part of the html table which would require me to include practically the entire page in the parent view due to the structure of the table, and in this case lots of html data unnecessarily would be sent to the browser at each request - defeating the purpose of an ajax call/partial update (correct me if i'm wrong).
Im sorry I misread, i thought you wanted to call an action method statically. If you want to update 2 parts with one click then I dont really now how you would do it with the included apis. What you could do is create a little javascript (jquery!) that takes over the link´s click, and then have the script load the render page with ajax.
I´ll post an example in a few minutes :P
<script src="../../Scripts/jquery-1.3.2.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$("#TheLink").click(){
$("#PlaceToUpdate1").load("/Controller/Method/View1");
$("#PlaceToUpdat2").load("/Controller/Method/View2");
}
});
});
</script>
im not sure if that will work exactly like that (no compiler, just top of my head) but its something like that. Of course the link should be a dummy link that doesnt do anything, since the script is the one actually doing it (though you can intercept the links methods if you send back a false or something like that)
You could manually construct the partial views in HTML helper methods. However, the feasibility of that approach depends on whether or not the partial views will be reused in other pages. I build a data grid control from scratch using HTML helper methods. Some of my pages have three or four of these data grids managed by a jQuery accordion control to reduce the screen footprint. I chose building an HTML helper for a number of reasons. First, I expected to use this control throughout my applications. Second, I didn't want to burden my views with a bunch of conditional logic. Finally, I wanted to be able to change the grid's configuration (including the model) within the view, so I wouldn't have to recompile every time I changed it. The grid supports both LINQ-to-SQL models and user-defined classes (using reflection), has a built-in pager control and a search mechanism that supports multiple search fields in a grid. I also set up the columns so that they can either display formatted text, link to a controller action or hold a mailto: link. Within the grid itself, you can define the model to populate the grid, optionally set the columns to display, specify the action and controller for creates, and specify a JavaScript function for deletes (because I use the jQuery dialog plugin for confirmation messages). All these changes are managed in the view itself.
Learning how to leverage HTML helper methods gives you the closest thing to ASP.NET server controls that MVC provides.

Categories

Resources