The grid component fails to display data from the store in ext js version 6.0.0

While studying the book 'Mastering Ext Js', I encountered a problem with the Grid Panel not loading data from the store. Despite checking the Json format server, everything seems to be fine and there are no errors in the console.

Below is my model class:

Ext.define("pg.model.security.User", {
extend: 'Ext.data.Model',
idProperty: 'userName',
fields: [
    {
        name: 'userName'
    }, {
        name: 'roleId'
    }, {
        name: 'fullName'
    }, {
        name: 'emailId'
    }, {
        name: 'mobileNumber'
    }, {
        name: 'landLineNumber'
    }, {
        name: 'picture'
    }
]
});

Here is the store class:

Ext.define('pg.store.security.Users', {
extend: 'Ext.data.Store',
requires: [
    'pg.model.security.User' // #1
],
storeId:'userStore',    
model: 'pg.model.security.User', // #2
proxy: {
    type: 'ajax',
    url: 'http://localhost:8080/parkgarau-ws/ws/park/userlist',
    reader: {
        type: 'json',
        root: 'data'
    }
}
});

I am able to successfully retrieve JSON format from the URL provided.

{"code":200,"message":"Success","data":"[{\"userName\":\"admin\",\"roleId\":\"SYS_ADMIN\",\"fullName\":\"Bibek Shakya\",\"emailId\":\"[email protected]\",\"mobileNumber\":\"9843598726\",\"landLineNumber\":\"014323565\",\"picture\":\"index.jpg\"}]"}

Here is my view class extending Grid Panel:

Ext.define('pg.view.security.UsersList', {
extend: 'Ext.grid.Panel',
alias: 'widget.userslist',
frame: true,
store: Ext.create('pg.store.security.Users'), // #1
columns: [
    {
        width: 150,
        dataIndex: 'userName',
        text: 'Username'
    },
    {
        width: 200,
        dataIndex: 'fullName',
        flex: 1,
        text: 'Name'
    }, {
        width: 250,
        dataIndex: 'emailId',
        text: 'Email'
    }
]
 });

This is my controller class:

Ext.define('pg.controller.security.Users', {
extend: 'Ext.app.Controller',
views: [
    'security.Users' // #1
],
init: function (application) {
    this.control({
        "userslist": {// #2
            render: this.onRender
        }
    });
},
onRender: function (component, options) { // #3
    this.getStore('userStore').load();
}
});

Answer №1

I finally identified the issue - it was related to the json format. The problem occurred when the format included '/'.

{
 "code":200,
 "message":"Success",
 "data":"[{\"userName\":\"admin\",\"roleId\":\"SYS_ADMIN\",\"fullName\":\"Bibek Shakya\",\"emailId\":\"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="88eae1eaede3c8ecfae7fbeda6ebe7e5a6e6f8">[email protected]</a>\",\"mobileNumber\":\"9843598726\",\"landLineNumber\":\"014323565\",\"picture\":\"index.jpg\"}]"}

However, once I corrected the json format, everything worked perfectly.

[{"userName":"admin","roleId":"SYS_ADMIN","fullName":"Bibek Shakya","emailId":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="40222922252b0024322f33256e232f2d6e2e30">[email protected]</a>","mobileNumber":"9843598726","landLineNumber":"014323565","picture":"index.jpg"}]

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 lack of error responses from Backend RestAPI with Axios

I am currently facing an issue with receiving a response from my backend system (Node.js Express RestAPI). exports.send = function(req, res) { console.log("sent function running!") let contact = new Contact(req.body) contact.send() ...

The array is failing to pass through ajax requests

Here is the JavaScript code snippet for making an AJAX call. In this scenario, the code variable is used to store a C program code and then pass it on to the compiler.php page. function insert(){ var code = document.getElementById("file_cont").val ...

Registration process in Node Express application encounters persistent loading when accessed through Postman

I've been working on a signup model for user accounts in Node.js, but when testing it in Postman, I encountered an issue where there was no response or failure. This left me stuck and I received the following error message in my terminal: Unhandled ...

Streamlined method for handling child elements within the DOM

I am striving to achieve a randomized shine effect on specific text using CSS animation. I currently have a functioning code, but I am interested in learning if there is a more efficient or straightforward solution. HTML: <span class="foo"> < ...

Using jQuery to pass multiple data-id attributes via AJAX

Having various tooltip links with distinct "data-id" attributes is a common scenario. <a href="" class id="tooltip" data-id="125">Link</a> <a href="" class id="tooltip" data-id="38">Link 2</a> In such instances, the "125" or "38" f ...

Tips for building an interactive jQuery data table using JSON information and AJAX requests

Currently, I am attempting to develop a dynamic data table using jQuery and JSON. My objective is to extract the keys from the JSON data and utilize them as headers in the table, while the values within those keys will be displayed as rows. Here's th ...

What is the best way to change a JavaScript variable into a PHP variable?

I am interested in converting my JavaScript variable to a PHP variable... Currently, I have the following scenario - in the code below there is a variable e, but I would like to utilize e in PHP as $e: <script> function test() { var e = documen ...

Tips for customizing the appearance of the active item in the navigation bar

Currently, I am developing a project with React.js using HTML, CSS, and JavaScript. My goal is to enhance the visual appeal of the active navigation item in the navbar by adding a white border around it. This way, the border will remain visible while the c ...

The logo and text appear to be out of place and not properly

My current project involves creating an email signature that is easily transferable to email programs like Outlook or Gmail. You can access the website for this project here: After pasting the signature into Gmail, it displays correctly. However, when pas ...

What is the process for transitioning from one HTML file to another in order to develop an iOS hybrid application?

I am looking to transition a webView page into a Spring-MVC structure with a hybrid format. My goal is to replace the current JSP file with an HTML file and place it within the ios project folder. The process of inserting the HTML test file was successful ...

Showing outcomes by making rapid consecutive AJAX requests

If you need a visual representation, I have a PHP script for a Hotel Management application that showcases a calendar (with columns representing days of the month and rows displaying prices per day). This script can be accessed in edit mode, where it gene ...

JQuery code embedded in HTML fails to run for the second time

I'm having some trouble with highlighting specific words on my HTML page. The page looks like this html page and here's the code: <!DOCTYPE html> <html> <body> <h1>Lorem ipsum dolor sit amet, consectetur adipiscing elit. ...

Looking for a versatile jQuery plugin that enables right-click functionality across different browsers?

I am currently using a context menu plugin that displays a context menu when an element is right-clicked. However, this does not work on elements embedded with ajax. To solve this issue, I am considering utilizing ajax live to trigger the context menu func ...

Is it possible for webdriver to retrieve the URL of the style sheet being utilized by a specific element?

Currently, I am working on a test scenario where I need to confirm that altering an option in a dropdown menu modifies the styling of the page. I am curious if Webdriver has the ability to retrieve the URL of the CSS document from an element. This appear ...

Serialization of Entity Framework entity to JSON with included related entities

I am facing a challenge with my User entity as it has numerous relations to other entities within the system. I am utilizing AngularJs and aim to serialize the User entity to JSON with only the included entities. Below is my select statement: var users = ...

SQL Querying JSON Arrays: Unleashing the Power

I need help querying a JSON file nested in an array within SQL Server. The JSON snippet is as follows: [ { "data_json": [ { "site": "Test Western Cape DC", "year&quo ...

What is the best way to retrieve a variable within an AngularJS controller?

I am working with a binding parameter eid: '@' Inside my constructor, you will find the following method: this.$onInit = () => { console.log('eid: ', this.eid) } console.log("eid in another section: ", this.eid) Upon running t ...

Validation on the client side for a form that is displayed within a bootstrap modal using ajax technology

Within my ASP.Net Core application, I am faced with the need to utilize validation on both the server side and client side in a bootstrap modal form. While I have successfully implemented server side validation, I have encountered difficulties when it come ...

Utilizing $scope in $compile in Angular: A Comprehensive Guide

Attempting to utilize my scope within a compile... I aim for a scenario where upon clicking a button, a div is generated containing the round number. main.controller('fightController', function($scope, $http, Services, $compile) { $scope.d ...

Retrieve the specific value of an item saved in localStorage

How can I extract the value from localStorage without retrieving the key name? localStorage.setItem('token', tokenJson); console.log(JSON.parse(localStorage.getItem('token'))); When I use console.log, it displays something like {"toke ...