Using ExtJS to populate a panel with data from various sources

I am currently working with an Ext.grid.GridPanel that is connected to a Ext.data.JsonStore for data and Ext.grid.ColumnModel for grid specifications.

Out of the 10 columns in my grid, 9 are being populated by the json store without any issues. However, I am facing difficulties with the last column as its data is dynamic and cannot be loaded in the same way as the others.

This particular column needs data from other datastores to be loaded first. Once these datastores are loaded, I have to extract the relevant information and insert it into a column within my json store in order to display it in the final column of the grid.

 var JSONSTORE = new Ext.data.JsonStore ({
    // Store Configs
        autoLoad: true,
        url: 'json_data_call.php',
        baseParams: {action: 'read'},
    // Reader Configs
        storeId: 'store1',
        idProperty: 'store1',
        root: 'data',
        sortInfo: {
            field: 'field_name',
            direction: 'ASC'
        },
        fields: [
            {name : 'field_name', type: 'string'},
            {name : 'field_name', type: 'string'},
            {name : 'field_name', type: 'int'}
        ],
        autoSave: false
    });

JsonStore.on('exception',JsonSave,this);

JsonStore.on('load',function(){


    autoDiagnosticsJsonStore.warn_err_loaded = true;

    if(autoDiagnosticsJsonStore.warn_err_loaded)
    {
        console.log(autoDiagnosticsJsonStore);
    }else{
        console.log('ERROR');
    }

});


/*
 * ColumnModel
 */
var ColumnModel = new Ext.grid.ColumnModel ({
    defaults: { menuDisabled: true },
    columns: [
        {header: 'Type',    hideable: false, sortable: false, dataIndex: 'ERR_TYPE',
            renderer: function(value, metaData, record, rowIndex, colIndex, store) {
                if (record.data.ERR_TYPE == 'WARNING') {
                    metaData.css = 'cog_bg_orange';
                }
                if (record.data.ERR_TYPE == 'ERROR') {
                    metaData.css = 'cog_bg_red';
                }
                return value;
            }
        },
        {header: 'Item Found', hideable: false, sortable: false, dataIndex: 'ERR_MSG', width: 900, css: 'font-family: lucida console, monospace;'}
    ]
});

var errorGrid = new Ext.grid.GridPanel({
    id: 'nmerrorGrid',
    enableColumnMove: false,
    autoHeight: true,
    xtype: 'grid',
    ds: JsonStore,
    cm: ColumnModel,
    sm: new Ext.grid.RowSelectionModel({singleSelect: true})
});


$error_panel = "

var errorPanel = new Ext.Panel({
    title: 'field_name',
    collapsible: true,
    anchor: '98%',
    height: 300,
    frame: true,
    layout: 'fit',
    items: [ errorGrid ]
});`

Answer №1

It seems like you are looking to introduce a new field for data in the store, which is calculated once the store is populated.

To achieve this, you can define a model for the records in your store and create a calculated field based on the record's values.

Here is an example:

Ext.define('User', {
    extend: 'Ext.data.Model',
    fields: [{
       name: 'firstName',
       type: 'string'
    },{
       name: 'lastName',
       type: 'string'
    },{
       name: 'fullName',
       calculate: function (data) {
         return data.firstName + ' ' + data.lastName;
       }
   }]
});

In this model, the 'fullName' field is generated using the existing records' values. You can then add your model to the store using model: 'User' instead of the fields configuration.

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

Discovering the presence of a NAN value within a JSON string

Consider the following scenario: I have a function that receives jsonData in JSON format, and I want to validate the variable jsonData to check for NaN. How can I achieve this? function save() { var jsonData = getEnteredValue(); $.ajax({ ...

Send the JSON output to the controller function

Hello there! I am new to asp.net mvc and I'm looking for a way to pass JSonResult data to a controller method. In my View, I have set up a table like this: <table id="tbl_orderItems" class="table table-striped table-bordered table-hover dt-respo ...

Filtering without the includes() Method

I have two Objects that are structured as follows: export const recipes: Recipe[] = [ new Recipe( id: "Green", scenario: ["1", "2"]), new Recipe( id: "Blue", scenario: ["1", "2","2"]) ]; export const scenarios: Scenario[] = [ new Scenario( id: "1 ...

What steps are needed to troubleshoot and resolve issues with integrating Google reCaptcha in an AWS Lambda

I'm encountering an issue with my lambda function which is intended to validate google recaptcha. Despite sending the correct data (the response) from the client, I consistently receive a console message stating "verification failed". Below is the cod ...

Using multiple main.js files with RequireJs in Play Framework 2.1.1 Java: A step-by-step guide

While working on a single-page app with AngularJs + RequireJs in Play Framework 2.1.1, I encountered an issue regarding the structure of my application. The project consists of two main sections - an admin dashboard and a normal website - both housed withi ...

Executing a function within a VueJs 2 component immediately after it has finished loading

How can I retrieve data after a component has finished loading? When I initialize my Vue instance and load the component, the template loads correctly but the functions in the mounted lifecycle hook are not executed, causing the stats object to remain empt ...

Testing XMLHttpRequest with Jasmine: A Complete Guide

Is there a way to test the onreadystatechange function on XMLHttpRequest or pure JavaScript AJAX without using jQuery? I need to do this because I'm working on a Firefox extension. It seems like I may have to use spies, but I'm having trouble bec ...

Troubleshooting: Issue with Angular 2 bidirectional data binding on two input fields

Hi there, I am encountering an issue with the following code snippet: <input type="radio" value="{{commencementDate.value}}" id="bankCommencementDateSelect" formControlName="bankCommencementDate"> <input #commencementDate id="bankCommencementDat ...

ColdFusion's powerful search form utilizes the advanced capabilities of Ajax to

I am currently seeking a technique such as a search form or form filter for a hotel finding website. My specific query revolves around utilizing coldfusion to create a search form with ajax functionality. Any ideas or tips on how to achieve this would be ...

Using AJAX to search through paginated pages is quite simple and effective

Currently, I have developed a JavaScript script that filters names within a list. However, a problem has arisen with pagination - as the list paginates, I am unable to retrieve names without refreshing the page. Is there a way to use AJAX to access and dis ...

Exposing a factory JS variable globally within an AngularJS environment

I am trying to access a variable created within a factory in another function in my AngularJS controllers. How can I achieve this and make the new calculated value available? The variable I want to use is result.data.bkor_payamount = result.data.bkor_paya ...

You cannot add properties to an object within an async function

I am attempting to include a fileUrl property in the order object within an async function, but I am unable to make it work properly. My expectation is for the order object to contain a fileUrl property once added, but unfortunately, it does not seem to b ...

Is Angular 2 Really Suitable for Multi-Page Applications?

I am currently working on a multi-page app using Angular2 and have noticed that the load times are slower than desired when in development mode. While searching for solutions, I came across a thread on stackoverflow that explains how to set up Angular2 fo ...

JavaScript Tip: Effortless method to confirm the presence of duplicate values within an array

Similar Question: Best method for identifying duplicate values in a JavaScript array If I have an extensive array containing thousands of elements, I am looking to check if there are 2 or more elements with identical values and return true. I unders ...

Looking to spice up your static HTML site? Dive into the world of Ruby on

I recently developed an app that features a static HTML webpage containing text and images, and now I'm interested in incorporating Ruby on Rails to explore its capabilities further. After creating a basic RoR application, I copied the HTML content f ...

Update the numerical data within a td element using jQuery

Is there a way to use jquery to increase numerical values in a <td> element? I've attempted the following method without success. My goal is to update the value of the td cell by clicking a button with the ID "#increaseNum". Here is the HTML st ...

Error: The TypeScript aliases defined in tsconfig.json cannot be located

Having trouble finding the user-defined paths in tsconfig.json – TypeScript keeps throwing errors... Tried resetting the entire project, using default ts configs, double-checked all settings, and made sure everything was up-to-date. But still no luck. H ...

How to address additional attributes received from the server in Next.JS

Encountering an error while trying to render a canvas with specified height and width within a child component in a NextJs app. The issue arises when attempting to integrate this mouse effect into my NextJS application. Everything functions correctly until ...

How can I troubleshoot my inability to map JSON object data in Next.js?

I have been working on displaying JSON data retrieved from the backend. The process involves using a useEffect hook to fetch the data: const [backendData, setBackendData] = useState(null) useEffect(() => { const fetchUserData = async () => { ...

Combining v-on:click and v-link in Vue.js

I'm currently working on a Vue.js application and I am in the process of creating a login system that involves multiple components. Within my App.vue component, which serves as the main component with the navigation bar, there is a button that looks ...