Issue with adding checkboxes to formpanel in ExtJS: Incorrect state reported

I have a fromPanel and I'm trying to achieve the following:

var linkPanel = new Ext.FormPanel({
    ...
});
var records = layers_store.getRange();
for(var i = 0; i < records.length; i++) {
    var layer_checked;
    console.log(records[i].data);
    if(records[i].data.checked == 'true') {
        layer_checked = true;
    } else {
        layer_checked = false;
    }
    console.log(layer_checked);
    linkPanel.add(new Ext.form.Checkbox({
        boxLabel : records[i].data.layer_name,
        name : records[i].data.layer_name,
        checked : layer_checked,
        handler : ...
        }
    }));
}

Also, in another part of my code, the layers_store is being updated.

When I check the console, I see:

({layer_id:"1", layer_name:"\u041F\u0435\u0440\u0432\u044B\u0439", checked:"false"}) 
false 
({layer_id:"2", layer_name:"\u0412\u0442\u043E\u0440\u043E\u0439", checked:"true"}) 
true 

This indicates that the first checkbox should be unchecked. However, it remains checked for some reason.

What could be going wrong?

edit:

Answer №1

The solution to this issue may vary based on the specific version of ExtJS being utilized. Let's proceed with the assumption that it is version 4.0.

When utilizing the getRange() method of Ext.data.Store, which returns an array of records in the form of Ext.data.Model objects, you cannot access their properties as though they were simple array indexes.

To access them properly, try using the following syntax:

records[i].get('layer_id'); 
records[i].get('layer_name'); 
records[i].get('checked');

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

A guide on combining two native Record types in TypeScript

Is it possible to combine two predefined Record types in TypeScript? Consider the two Records below: var dictionary1 : Record<string, string []> ={ 'fruits' : ['apple','banana', 'cherry'], 'vegeta ...

Transform a nested JSON Object into a customized array structure

My task involves converting a nested JSON object into a specific format, as demonstrated below: let jsonObj ={"data": { "cardShop": { "cardData": { "cardTitle": "The Platinum Card<sup> ...

Number each element in sequence

Looking to give sequential numbering to elements by iterating through them. For instance, if there are 6 input elements, the goal is to update their names correspondingly like "name=input1", "name=input2", and so on. This involves using a for loop to reas ...

Try opening a fresh page instead of displaying a pop-up that says "your message has been sent"

I am currently utilizing the "Agency" one-page Bootstrap template. Upon successful form submission and email sending, a popup message is displayed. My preference is to have a new page open instead of the popup. $(function() { $("input,textarea").jqBoot ...

Learn how to integrate ES6 features into your nodejs/expressjs application using either Gulp or Webpack

I am looking to incorporate ES6 features into my nodejs/expressjs application. Currently, I am using Gulp for JavaScript compilation and setting up live reload. What steps do I need to take in order to compile the es6 code to standard js within my exis ...

Unable to choose options fetched from the API in Select2 Ajax

I've been struggling to populate a select input with data from my API using Select2. Despite having everything set up correctly, I'm facing an issue where I can't select anything once the results are displayed. I've been working on this ...

When the click event occurs, add a class. After a delay using a timeout function, remove the added

I am currently using Jimdo and I have a section where I can edit all the codes, which is working fine except for one feature. Any assistance would be greatly appreciated! Here is the code that adds a class to an animated SVG image with its status set as d ...

The sticky navigation bar hack (implementing fixed positioning with jQuery)

Essentially, when the navigation bar (or any other element) reaches the top of the page or window, a class called "sticky" is added to the element and CSS styles it as fixed. This functionality acts like an IF statement - if the element is far from the top ...

Troubleshooting: Custom JQuery function not functioning as expected

I am currently facing an issue with the jQuery in my website while trying to implement a portfolio element. It seems to be related to the changePortfolio() function, but I am unsure of how to resolve it. $('.projects a[href^="#"]').on('clic ...

What is the technique for retrieving the data-id value and transferring it to a different page with jQuery's post method?

Here is the code I'm working on: <a href="#view_contact" class="btn btn-info btn-xs view" data-id="<=$row['ADMINISTRATOR_ID'];?>" data-toggle="modal">View</a> I'm trying to fetch the value of data-id and pass it to a ...

Tips for ensuring proper dependency regulations in javascript/typescript/webpack

In essence, I am in search of a method to limit dependencies, similar to how one would manage different projects (libraries) in Java or C#. Think of it as friend or internal access modifiers. I'm considering various approaches to accomplish this (suc ...

What is the proper way to format parameters being sent to the server using JavaScript on the back end

Struggling to make the following code work in my ASP.NET demo application, looking for some guidance here. Check out the javascript code below: function checkUserName() { var request = createRequest(); if (request == null) { alert("Unable ...

Is Meteor.js the solution for time-triggered server requests?

We are currently in the process of developing an application that matches users from a database every Wednesday and Friday. How can we achieve this using Meteor? In the server code, I am considering organizing this functionality within a timedserver.js fi ...

Bidirectional data binding in AngularJS for <option> elements generated from an AJAX request

I have built a Controller called WebsiteController with the following functionality: JApp.controller('WebsiteController', function($scope, $resource) { var UsersService = $resource('/auth/users', {}); $scope.adding = false; ...

How come I can't capture discord.js promise rejections within event callbacks?

As I delve into creating a discord bot, I encountered an interesting problem. To simplify things, here is a snippet that encapsulates the issue at hand: const Discord = require('discord.js'); const client = new Discord.Client(); client.on(&apo ...

How to display an object in JS format using React?

Currently, I am tackling a project that presents me with the following situation: myjson: { completeName: "my name is {this.state.myName+ " "+this.state.surname}" } component.js var Component = React.createClass({ getInitialState: function() { ...

Triple the Charts: Highcharts Vue Component combines three dynamic charts into one powerful visual tool

looking for help with creating a complex chart Hello, I have a task of creating what seems to be 3 charts in one design. I am able to create the two scattered charts, but the column charts are proving to be challenging. Thanks to Wojciech Chmiel, I manage ...

Encountering an issue with postman where properties of undefined cannot be read

I am facing an issue while trying to create a user in my database through the signup process. When I manually enter the data in the create method, it works fine as shown below: Note: The schema components are {userName:String , number:String , email:Stri ...

Error: JSON parsing failed due to an unexpected token 'S' at position 17

Trying to troubleshoot a syntax error in JSON.parse() within a product warranty registration process. Transitioning from Java to AngularJS for this project, I have an API built in PHP handling the back-end operations and a controller managing communication ...

What is the best way to set a value for a specific column using JavaScript in a RadGrid?

One of my requirements involves having a Radgrid where all rows are always in edit mode. Specifically, I am looking to implement a functionality in one of the columns where after an item is edited, all rows in that column should take on the same value. Her ...