Is using a DWR proxy with a JSON store possible in ExtJS?

I'm currently working on configuring a JsonStore to utilize a function that runs asynchronously and accepts arguments, but the process is a bit confusing for me.

The function myMethod requires a callback, but how can I connect the callback data to the JsonStore?

store = new Ext.data.JsonStore({
    proxy: new Ext.data.DirectProxy(
    {
        directFn:(new function(){return MyDwrService.myMethod('test')}),
    }),
    autoLoad:true,...

I attempted to use a DwrProxy implementation, however, when I omit passing fields to the JsonReader, my grid does not display any data. On the other hand, if I do include fields, it generates numerous empty rows. What am I missing here?

   store = new Ext.data.Store({
        proxy: new Ext.ux.data.DwrProxy({
            apiActionToHandlerMap:{
                read: {
                    dwrFunction: MyService.myMethod,
                    getDwrArgsFunction: function() {
                        return ["testUser"]
                    }
                }
            }
        }),
        reader: new Ext.data.JsonReader({fields:myFields}),
        autoLoad:true,
    fields:myFields,
    remoteSort:true
});

Answer №1

Implement DWR3 utilizing the JSONP feature to avoid the necessity of a proxy server.

Answer №2

It is crucial to have fields specified in the reader, but I am confused as to why there are empty rows present. I am certain that we do not receive any records with missing data - perhaps setting allowBlank:false will resolve this issue. For reference, here is the code snippet:

var myReader = new Ext.data.JsonReader({
    root : 'objectsToConvertToRecords',
    idProperty: 'id',
    fields : [
        {name: 'id', allowBlank:false},
        {name: 'foo', allowBlank:false},
        {name: 'bar', allowBlank:false}
    ]
});

var dwrProxy = new Ext.ux.data.DwrProxy({
    apiActionToHandlerMap : {
        read : {
            dwrFunction : RemoteClass.remoteReadMethod,
            getDwrArgsFunction: function(request, newData, oldData) {
                return [request.params.myId];
            }
        },
        create : {
            dwrFunction : RemoteClass.remoteCreateMethod,
            getDwrArgsFunction: function(request, newData, oldData) {
                return [newData];
            }
        },
        update : {
            dwrFunction : RemoteClass.remoteUpdateMethod,
            getDwrArgsFunction: function(request, newData, oldData) {
                return [newData];
            }
        },
        destroy : {
            dwrFunction : RemoteClass.remoteDestroyMethod
        }
    }
});

var store = new Ext.data.Store({
     proxy: dwrProxy,
    reader: myReader,
    writer : myWriter,
    autoLoad : true,
    autoSave: true,
    baseParams: { tiploc: this.tiploc }
})

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Troubleshooting: AsyncFileUpload functionality not working within Listview's Insert, Edit Itemtemplate, and EmptyData Template

Having trouble with AsyncFileUpload not working inside Listview Insert, Edit Itemtemplate and EmptyData Template. The following are my Client Side Functions: function AttachmentUploadSuccessful() { debugger; var textError = $(".AttachmentError"). ...

Guzzle version 6.x is not delivering the desired outcome as expected

My restful API returns a specific response when POSTMAN is run on the given URL: POSTMAN RUN URL DELETE https://www.example.com/api/v1/Blog/blog/13 { "status":"Failure", "message":"The specified blog post could not be found" } A ...

Challenges with saving form data when using dropdowns that are dependent on each other

I'm encountering an issue with a dependent dropdown. Everything works smoothly on the frontend, providing optimal filtering, but I'm facing problems with saving data on the backend. Please select a valid option. The chosen option is not ava ...

Tips for refreshing the tawk.to widget when the language changes with the help of i18next

Utilizing i18n-jquery for language switching and integrating the tawk.to chat widget, I've successfully loaded different languages on page reload. However, due to i18n not refreshing the page (which I don't want to do), I need to figure out how t ...

Eslint error: Attempting to assign to rvalue in ES6 function definitions

Currently, I have eslint configured like this: { "extends": "google", "installedESLint": true } When running lint on the following function: app.get('/', (req, res) => { console.log(req); res.send('hello world') }); I ...

Component not refreshing when state changes occur

I have a unique react application that resembles the one showcased in this codesandbox link https://codesandbox.io/s/eatery-v1691 By clicking on the Menu located at the bottom center of the page, it triggers the display of the MenuFilter component. The M ...

Error: Objects cannot be used as constructors

An Azure Function using JavaScript HTTP Trigger posts activity in a Slack online community for customers. It has been functioning successfully for many years, but after upgrading from version ~2 to ~4, it started throwing an error stating Entities is not ...

Execute a series of functions with identical arguments, excluding the first function, and output the result of the second function using the plumber package in

I'm encountering an issue with my main function which contains two sub-functions, fun1 and fun2. Both sub-functions have the same argument but only fun2 is being printed while fun1 remains elusive in the plumber in Swagger console. The reason for this ...

Exploring the power of the cssContainingText locator feature in Protractor

Currently working on a framework utilizing Protractor, I encountered an issue with the cssContainingText locator from the Protractor API. The locator threw an invalidElement exception, which puzzled me. The structure of the HTML page appears as follows: ...

Assign the value from JavaScript to the element with the "ng required" attribute, without resetting frm.$error.required to false

My situation involves using a button with ng-style that relies on frm.mybtn.$error.required as follows: ng-style="frm.mybtn.$error.required?{'border-color':'#a94442'}:''" I am updating the value of the button from JavaScript ...

"Set a timeout for an HTML markup to be displayed in an AJAX

Is there a way to automatically hide the success message that appears after an AJAX request is successful? For example, after 2 seconds of displaying the message, I want it to disappear. Here's the code I have: $.ajax({ url : 'process/regis ...

Adding parameters to a URL is a common practice

"Adding additional information to a URL that was previously included?" I apologize for the confusing title, but I can't find a better way to phrase it. Perhaps an example will make things clearer. Let's say I have URL 1: http://example.com/?v ...

Issues encountered while utilizing the jQuery function $.ajax()

I'm encountering issues with utilizing ajax in conjunction with jQuery... Here is the script I am using: $(document).ready(function() { $('rel[close]').click(function() { $(this.parent).close(); }); $('a[rel=trac ...

Change the text field's border color if the field is not empty

On my website, there is a TextField where users can enter values to perform a site search. My question pertains to the border color of this field. Normally, the border color is black when the field is not in use. However, when a user clicks on the field an ...

Mongoose not functioning properly with .sort()

For some reason, the .sort() function just doesn't seem to be functioning properly for me. However hard I try, it simply does not sort the data as expected. I am outputting the data using Handlebars {{Book}} router.get("/", (req, res) => { Book ...

A different and more efficient way to address the issue at hand

During a recent interview, I was asked the following question and despite being able to solve it, the interviewer pointed out that my code was not optimized. Is there anyone who can help me with an optimized solution? Question : Given an array array1, rea ...

What could be causing this React/Javascript object to be undefined?

I've been attempting to convert this JSON into JavaScript objects, but all my efforts have resulted in undefined values. The objects simply won't work as intended. Here is the code I'm using with the getStaticProps method to extract objects ...

Swap out a div identifier and reload the page without a full page refresh

I am interested in learning how to dynamically remove a div id upon button click and then add it back with another button click to load the associated CSS. The goal is for the page to refresh asynchronously to reflect these changes. So far, I have successf ...

Creating a new JavaScript object using a Constructor function in Typescript/Angular

Struggling with instantiating an object from an external javascript library in Angular/Typescript development. The constructor function in the javascript library is... var amf = { some declarations etc } amf.Client = function(destination, endpoint, time ...

I'm having trouble getting jQuery to work properly with Bootstrap buttons

In simple terms, my objective is to have two buttons on a page where "1" is displayed when the first button is pressed and "2" is displayed when the second button is pressed. This functionality works fine with radio inputs, but when I incorporate button la ...