9

I did successfully add a row double click event listener to my grid by:

listeners : {
    itemdblclick: function(dv, record, item, index, e) {
        alert('working');
    }
},

Now, I need to get the exact value in third column at the selected row, how can I do that ?

EDIT

Okay found it:

listeners: {
    itemclick: function(dv, record, item, index, e) {
        alert(record.get('name'));
    }
}

but seems like the result of record.get('name') is not a text! its an object but I cannot handle it as if it a text. any body has any idea ?

EDIT

For example, if I pass the name to search function: Search(record.get('name')); this won't work. but if I pass it this way: Search('Mike'); it works !

4
  • Will you know which column is bound at the third? IE, do you already know the dataIndex? Commented Dec 10, 2012 at 6:53
  • Are you sure? What object does record.get() give you?? If your data is a string, it'll give you a string. Can you inspect it in a debugger? Commented Dec 10, 2012 at 10:02
  • yes I am sure, I got the name as string successfully but when I pass it to another function, it can't handle it, on the other hand if I pass the name itself (I type it), function works fine. Commented Dec 10, 2012 at 10:42
  • you can look at your record data using console.log(record.data) or in your case console.log(record.get('name')). don't use alert() Commented Dec 10, 2012 at 11:26

2 Answers 2

4

Ensure that

  • Your property name is really lowercase 'name' and not 'Name'
  • Print the value of the field into the console with console.log(record.get('name')) or use the direct access by typing console.log(record.data.name) or console.log(record.data['name']). Basically all should return the same.
  • To cast a value to string apply '' on the fly like var myVar = 2; myVar = myVar + ''; // now print 20 as string
Sign up to request clarification or add additional context in comments.

Comments

0

Try with,

listeners: {
itemclick: function(dv, record, item, index, e) {
 var selectedRec = dv.getSelectionModel().getSelected();          
 alert(selectedRec.get('name')); //Will display text of name column of selected record
}

2 Comments

got this error: Object [object Object] has no method 'getSelected'
@Noon You cannot call getSelected() this before 4.x. Use getSelection() instead. But doing this without mutliselection turned on in case of a click-event is not recommend, you have already the record as second argument!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.