Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
Using function, in place of editurl?
04/12/2010
01:05
Avatar
jdege
Member
Members
Forum Posts: 8
Member Since:
03/12/2010
sp_UserOfflineSmall Offline

JqGrid allows me to use a javascript function, instead of a URL, for datatype.  This has allowed me to get data from an odd source, and to manipulate it into json that I can populate the jqGrid with, using addJSONData().

My problem now is with editing.  If I set editurl to a javascript function, I get an error:

Error Row: 4 Result: 405:Method Not Allowed Status: error

What do I need to do to have edit pass its data to a javascript function, instead of to a URL?

04/12/2010
01:45
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

I don't recommend you to use datatype as function if it is not really required. In very old version of jqGrid (more as one year old) was less support for different options of ajax requests. Since at least more then one year you can use new options (see here and here for example) so you can get data, edit data accessing practically any data source. To write more advices for you I have to know the technology which you use on the server side.

Best regards
Oleg 

04/12/2010
02:11
Avatar
jdege
Member
Members
Forum Posts: 8
Member Since:
03/12/2010
sp_UserOfflineSmall Offline

The server-side is a page webmethod on an asp.net web form.  That is, we have a method like this defined in a .aspx.cs page:

[WebMethod()]

[ScriptMethod(ResponseFormat = ResponseFormat.Json)]

public static MyData getMyData(Dictionary<string, object> postData)

{

MyData myData = new MyData();

return myData;

}

 

Note, this is ASP.NET web forms, not ASP.NET MVC.

And it's a WebMethod defined within a .aspx page, not in a .asmx web service. 

It's called from javascript with:

PageMethods.getMyData(postdata, successCallback, errorCallback);

I've not found examples on how to make a simple data load work, calling a page webmethod.  So I'm using a function datatype.

If there's a way to make data load work, calling a page webmethod directly, I'd love to learn about it.  And if I can make add, edit, and delete work, using page webmethods, I'd like to know how to do that, too.

But even if all of that can be done, I still want to know how to use a local javascript function for handling add, edit, and delete.

04/12/2010
03:56
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

From the performance side the best choice will be to has a WCF service published in the same web side. You can find the example here. The second choice will be an ASMX web service (see here). All this solutions you can easy integrate as a part of the ASP.NET Web Form site. It will work for pure HTML pages also. To edit jqGrid data see this. This one and this are the answers on the MVC questions, but almost all can be used also for WCF/ASMX can be probably also interesting.

The main advantage of the WCF/ASMX way corresponds to you current way is native support of all jqGrid features including paging, sorting and filtering (searching) of data.

Best regards
Oleg

06/12/2010
17:27
Avatar
jdege
Member
Members
Forum Posts: 8
Member Since:
03/12/2010
sp_UserOfflineSmall Offline

Going with a separate webservice, whether WCF or ASMX, may provide better performance, but it increases code complexity.  In some situations, performance is the dominant concern, and the additional complexity is acceptable.  In others, it is not.

In my case, we're talking about a low-volume website, with a great many pages containg jqGrids, each of which will be used rarely, and will pull down only modest amounts of data.  Building separate webservices to feed each, rather than using page methods, is not the optimal solution.

At first glance, none of the examples you provided addressed my specific question.  For example, you've provided links to answer "the MVC questions", when I specifically stated that we weren't using MVC.

I'll look into them more deeply, though, to see if there is anything that applies.  But in the meantime, I'll ask again:

Is there a way to process add/edit/delete in jqGrid, using local javascript functions?

06/12/2010
18:11
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Sorry jdege,

but I don't agree with your statements about the complexity. If you rename one file so that it has just correct extension ASMX, you code

[WebMethod()]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static MyData getMyData(Dictionary<string, object> postData)
{
    MyData myData = new MyData();
    …
    return myData;
}

will work correctly. You should only fix parameter Dictionary<string, object> postData to parameters which are described in the links which I posted before (like int page, int rows, ...).

Your current implementation can follow that the results of getMyData method will be placed as a part of HTML page or some part of master pages will be added. Moreover view state with whole table contain could be send to or from the server. So you will have many additional problems and the "complexity" of the solution is now higher as with pure web service.

What you need to do is just choose in the "Solution Explorer" of your Visual Studio Project in contex menu the item "Add", then "New Item". Then choose you should choose "Web Service" template instead of "Web Form" and modify a little the code which will be automatically produced. It can sound complex only if you do this at the first time, but it is really very simple.

Best regards
Oleg

06/12/2010
18:28
Avatar
jdege
Member
Members
Forum Posts: 8
Member Since:
03/12/2010
sp_UserOfflineSmall Offline

I know how to implement a .asmx web service.  I've done it quite a number of times. But whether a webmethod is implemented as a page method, or as a part of a .asmx web service is irrelevant to the question I'm asking.

How do I process add/edit/delete, using local javascript functions?

06/12/2010
18:54
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

editurl as a function is not supported. You should use 'clientArray' in case of inline editing. Form editing had not full support of local editing. Probably now?

06/12/2010
20:40
Avatar
jdege
Member
Members
Forum Posts: 8
Member Since:
03/12/2010
sp_UserOfflineSmall Offline

Fair enough, thanks.

07/12/2010
19:02
Avatar
jdege
Member
Members
Forum Posts: 8
Member Since:
03/12/2010
sp_UserOfflineSmall Offline

Sorry to keep coming back to this.  I've tried your suggestions, and have made some good progress.

While digging through the code, I noticed a useDataProxy in grid.formedit.js.

Does this work?  Or is it simply a remnent of an earlier idea that never panned out.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
56 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information