This is a migrated thread and some comments may be shown as answers.

How to have parameterMap override but keep odata filters

11 Answers 1144 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Patrick Rioux
Top achievements
Rank 1
Patrick Rioux asked on 01 Mar 2012, 04:09 PM
Hi,

I'm using a kendo grid and I want to alter the JavaScript structure before doing the http call.My datasource type is odata.
The problem is as soon as I add the parameterMap the odata $filter, $skip, $top is no longer sent and formatted to odata.
I want to override this for the update operation only.
The example does that but there is no filter implemented (http://demos.kendoui.com/web/grid/editing.html) and therefore it is an incomplete example
.
parameterMap: function(options) {
alert(options.filter.filters[0])
}
I have access to the filters but how can I put back the standard behavior along with my custom needs.
I know there is a toOdataFilter function being used to convert these but struggling how to keep the standard odata support and adding my custom needs.

Anyone has already faced this issue and figure out how to handle this?
Thanks.

11 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 02 Mar 2012, 09:31 AM
Hi,

Currently, you may use the following code to call the default implementation of oData parameter map:

dataSource: {
      type: "odata",
      transport: {
          read: "URL",
          parameterMap: function(options, type) {
              options.foo = "bar"; // do something here
               
              return kendo.data.transports["odata"].parameterMap(options, type);
          }
      },
//...
}

Greetings,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Patrick Rioux
Top achievements
Rank 1
answered on 02 Mar 2012, 03:43 PM
Thank you very much. It fix the issue!
0
Patrick Rioux
Top achievements
Rank 1
answered on 02 Mar 2012, 06:16 PM
ok now, how can I get the callback string since I have overriten the parameterMap?

transport: {
parameterMap: function(data,operation) {
                    if (operation == 'read') {
                        return kendo.data.transports["odata"].parameterMap(data,operation)
                    }
                    else {
                        return {
                    $operation: function () { return operation},
                    $callback: function () { return ""},
0
Rosen
Telerik team
answered on 05 Mar 2012, 10:25 AM
Hello Patrick,

Could you please provide a bit more information about what you are trying to achieve?

All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Patrick Rioux
Top achievements
Rank 1
answered on 05 Mar 2012, 02:26 PM
Hi Rosen,
My updates to the server are good. The only problem I have is returning the call back string to the client-side.
When I commit my changes, how can I obtain the callback strin. Since I have override the paramaterMap, the callback string is not sent.
In order to send back in the update response the callback I need to send it to the server along with the models data.
This is to allow me to return:
jQuery171033428954028692415_1330953452468([{"ProductID":1,"ProductName":"Chai111","UnitPrice":18,"UnitsInStock":39,"Discontinued":false}])

Thank you.

Example if the http post parameters:
callback  jQuery171033428954028692415_1330953452468
models [{"ProductID":1,"ProductName":"Chai111","UnitPrice":18,"UnitsInStock":39,"Discontinued":false}]
0
Rosen
Telerik team
answered on 06 Mar 2012, 01:43 PM
Hello Patrick,

You do not need to get the generated by jQuery callback name and manually send it to  the server, with the latest (Q3 SP1 2011+)  official version of KendoUI it should be automatically send as $callback. Note that you should make sure you do not set is explicitly.

Greetings,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Patrick Rioux
Top achievements
Rank 1
answered on 06 Mar 2012, 03:23 PM
Thanks. I find out the issue, the dataType="jsonp" was missing. I now have the callback.
I noticed something, the parameter for the read is $callback and for the update/destroy is callback.
Now I returned the proper callback but the grid doesn't update automatically (the red marker remains).
Do I need to do something manually to refresh the grid?

 
0
Rosen
Telerik team
answered on 08 Mar 2012, 08:53 AM
Hello Patrick,

You should verify that the request send to the server during the update/create/delete operations is successive and the success function pass from the DataSource is executed. 

All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Patrick Rioux
Top achievements
Rank 1
answered on 08 Mar 2012, 05:00 PM
The error: method is called when I get a server-side error. I checked for the success status and this method is never called when the update has been perform successfully on the server.
Maybe I need to send a specific code to force the Kendo grid to be refreshed?
....
success: function () {
                    alert('Record(s) updated successfully.')
                    },
error: function(e)
                    {
                    // Code is the additional field to show in the error message. Title to show is taken from Kendo grid columns object.
                        alert('Update has failed!'+dtGetErrMsgFromResponseText(e.responseText,'Code', $("#grid").data("kendoGrid").columns));
             },
....
0
Rosen
Telerik team
answered on 09 Mar 2012, 08:11 AM
Hi,

Could you please provide a small sample which demonstrates the scenario you are trying to achieve and your implementation. This will allow us to get better understanding about your case and provide you with more to-the-point answer.

Greetings,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Alessandro
Top achievements
Rank 1
answered on 09 Mar 2012, 06:59 PM
Dear Rosen,

I was facing the same issue and this thread solved the problem.
I'd like to tell that you and your team are doing an excellent job. Congrats for the high quality Product.

Alessandro.
Tags
Grid
Asked by
Patrick Rioux
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Patrick Rioux
Top achievements
Rank 1
Alessandro
Top achievements
Rank 1
Share this question
or