Results 1 to 6 of 6

Thread: [OPEN] [6.5.1] RendererCell use wrong record

    Success! Looks like we've fixed this one. According to our records the fix was applied for REAC-291 in 1.1.1.
  1. #1
    Ext JS Premium Member
    Join Date
    Oct 2011
    Location
    Trieste, italy
    Posts
    33

    Default [OPEN] [6.5.1] RendererCell use wrong record

    I try to explain the problem with an example:
    Code:
    import React, { Component } from 'react'
    import { Grid, Column, RendererCell, Button } from '@extjs/ext-react';
    
    export default class MyExample extends Component {
    
        store = new Ext.data.Store({
            data: [
                { "name": "Lisa", "email": "[email protected]", "phone": "555-111-1224" },
                { "name": "Bart", "email": "[email protected]", "phone": "555-222-1234" },
                { "name": "Homer", "email": "[email protected]", "phone": "555-222-1244" },
                { "name": "Marge", "email": "[email protected]", "phone": "555-222-1254" }
            ]
        });
    
        render() {
            return (
                 <Grid store={this.store} ref={grid=>this.grid=grid}>
                 <Column text="name" dataIndex="name"/>
                 <Column text="Actions" dataIndex="name">
                     <RendererCell
                         renderer={(value, record) => (
                             <Button text='delete' handler={this.onCallClick.bind(this, record)}/>
                         )}
                     />
                 </Column>
             </Grid>
            )
        }
        onCallClick = (record) =>{
            this.grid.getStore().remove(record)
        }
    }
    Push the delete button at first row, then push the delete button at new first row... at first click the row is deleted, at the second click the passed record is the before deleted record.
    Am I in error or it's a bug?

  2. #2
    Sencha User
    Join Date
    Mar 2015
    Location
    Maryland
    Posts
    482

    Default

    I believe that's related to a known issue where the handler function isn't rebound on rerender. You can work around it by adding key={record.getId()} to the <Button> component. That issue will be fixed in reactor v1.1.1. It should be out in the next week or so.

    https://fiddle.sencha.com/?extreact#...or&fiddle/256k

  3. #3
    Sencha User
    Join Date
    Mar 2015
    Location
    Maryland
    Posts
    482

    Default

    Thanks for the report! I have opened a bug in our bug tracker.

  4. #4
    Ext JS Premium Member
    Join Date
    Oct 2011
    Location
    Trieste, italy
    Posts
    33

    Default

    Quote Originally Posted by Mark.Brocato View Post
    I believe that's related to a known issue where the handler function isn't rebound on rerender. You can work around it by adding key={record.getId()} to the <Button> component. That issue will be fixed in reactor v1.1.1. It should be out in the next week or so.

    https://fiddle.sencha.com/?extreact#...or&fiddle/256k
    Thank you Mark, but... have you a suggestion in case of two or more action button?
    In my case I have four button on every record

  5. #5
    Sencha User
    Join Date
    Mar 2015
    Location
    Maryland
    Posts
    482

    Default

    You can just append some string indicating the button's action to the key to make it unique within the parent. For example:

    Code:
    <Button key={`${record.getId()}.delete`} />

  6. #6
    Ext JS Premium Member
    Join Date
    Oct 2011
    Location
    Trieste, italy
    Posts
    33

    Default

    OK, it works.
    Thanks

Similar Threads

  1. Replies: 4
    Last Post: 5 Jun 2015, 10:57 AM
  2. [FIXED] getNode return wrong record after add new record
    By traxanos in forum Ext:Bugs
    Replies: 3
    Last Post: 17 Nov 2011, 10:37 AM
  3. getSelectedRecords return the wrong record
    By Gunny in forum Sencha Touch 1.x: Discussion
    Replies: 2
    Last Post: 28 Mar 2011, 4:11 AM
  4. record passed in getDetailCard - where am I going wrong?
    By irocker in forum Sencha Touch 1.x: Discussion
    Replies: 1
    Last Post: 19 Feb 2011, 10:46 PM
  5. [OPEN-407] API documentation wrong?
    By roady001 in forum Sencha Touch 1.x: Bugs
    Replies: 2
    Last Post: 28 Oct 2010, 7:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •