Code Monkey home page Code Monkey logo

Comments (6)

kktos avatar kktos commented on July 30, 2024

Wouldn't be useful to have a possibility to set the verb during the grid creating ?
The use of POST instead of GET would be useful.
That's not compliant with the REST use of the verbs, I know, but useful nevertheless ;)

from w2ui.

vitmalina avatar vitmalina commented on July 30, 2024

The GET, PUT, POST, DELETE is a new feature since 1.1 release. I am not very convinced about them, but it is indeed needed to be fully REST compliant. I do agree with you that GET does not look good for grid because it sends lots of data to the server in URL. I wanted POST for it too. I have agreed to do this because of suggestions from other developers. However, I did have already one problem with it. Some hosting providers deny by default any methods besides GET and POST. And it requiers additional effort to request it. I think the library should give developer an option to do fully rest or not.

So, I have been thinking of creating a global setting available for developer to change to use full REST complient interface or not. If not, then it will be like it was before. Pretty much any request that passes variables will go through POST, otherwise GET. You comments are welcome.

from w2ui.

adisesha avatar adisesha commented on July 30, 2024

I believe the better way is to give the user the option to make server call rather than grid making it.This gives user freedom to choose Http method, and does not force server to provide specific api for grid. Right now 'request' method assembles the param object and makes server call. Although there is a option to stop server call, the user needs to do what is done in 'complete' method.

from w2ui.

vitmalina avatar vitmalina commented on July 30, 2024

There are 2 events: onRequest and onLoad. First one is fired before any server call is made and this event handler will receive all assembled parameters that would be send to the server. The developer can change this list of parameters and the modified list will be sent. Or the developer can stop event flow and do the call on his own. If grid makes the call, then onLoad method will be fired when server responds but before it processes server results. The developer also can stop the event and process manually.

Please help me understand how this can be improved. To my mind, the developer has a way to do both (1) modify before and after the server call or (2) completely replace server call with his/her logic.

from w2ui.

adisesha avatar adisesha commented on July 30, 2024

The default behavior is absolutely useful if you have freedom to built server side REST api which accepts POST method and understands postData map that grid is sending.

We have a server side api which accepts only GET requests and parameter names are different. For example, in postdata map, search pramaters is array. In our case we pass them as query params. Say field names orderId, the query prams will be orderId=2&order_op=LIKE.

To satisfy my server currently I have to do the following.

  1. Stop the call by listening by handling before.
  2. Convert the postdata map to something my server understands.
  3. Receive response from server.

From here I need to do what 'complete' function in ajax call is doing in 'request' method. The function has critical features.
4. Hide status.
5. Fire events.
6. Show error message in popup.
7. etc etc

You can move steps 4 to 7 to separate function and make it available for calling. This way someone else need not repeat this steps.

You can look at the 'fnServerData'(http://datatables.net/usage/callbacks). What it does is,

  1. Whenever data is needed make call to 'fnServerData' with necessary params(similar to postdata) for server and a callback function.
  2. User will make call to the server.
  3. Once data is received, it is converted to the format that datatables expect and invoke the callback function it is passed.

With this approach, you can see that datatables need not even care about where the data is coming from(server or local). All it is doing is asking for data when it is needed.

Don't get me wrong w2grid has great functionality. Like any other component it is not possible to satisfy every user. Fortunately in this case, it fits for us with a slight modification. Right now I am trying to re-factor 'request' to fit our needs. If I am able to do it generically(I am a Java guy :) ), I will open pull request.

from w2ui.

vitmalina avatar vitmalina commented on July 30, 2024

I have added a setting

w2utils.settings.RESTfull = true

If it is false, which is default now, it will submit POST and in some cases GET. If it is true, it will be fully complient with REST. It will submit GET, POST, PUT, DELETE words when necessary.

from w2ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.