0

I am using extjs grid , and i put a render function on a coloumn of a grid

/** 
    * function for rendering the link
    **/
    function linkRenderer(data, cell, record, rowIndex, columnIndex, store) {
        console.log(record.id);
        if  (data != null)  {
            return '<a href="javascript:void(0)" onclick="resellerwindow('+record.id+')">' + data + '</a>';
        }
        return data;
    }

while on clicking the link i got an error that whatever the value of record.id is not not defined

Please suggest what solution i can do .

3
  • open firebug or similar and check the properties of record prior to calling linkRenderer. Chances are that you are not passing the thing you think you are. Commented Mar 17, 2011 at 10:42
  • What does the console.log output? Commented Mar 17, 2011 at 10:43
  • @ChrisR m getting the value in string like city name i am using here Commented Mar 17, 2011 at 10:45

3 Answers 3

1

Do you have a idProperty set for your store? set the idProperty to one of the values used to identify unique records. This will ensure that record.id is set to a value. For accessing all other values of the record, you will have to access them through record.data.proerty

Update: You need to use escape characters so that the string values are properly passed to the resellerwindow method:

<a href="javascript:void(0)" onclick="resellerwindow(\''+record.id+'\')"> + data + '</a>'
Sign up to request clarification or add additional context in comments.

8 Comments

Yeah ` idProperty: 'cityname',`
did you check your generated HTML is correct after rendering the grid? use firebug and check a particular cell's HTML
<a href="javascript:void(0)" onclick="resellerwindow(bangalore)">68</a> it is this
there you go.. you are missing a quotes it should be: resellerwindow("bangalore").. since you are passing a string to the method
Abdel nice idea of checking in firebug
|
0

But that's pretty clear the value of record.id is not define. Dah!

Comments

0

If the output of your console log is a string you are calling your function wrong, you are missing some quotes if record.id is a string.

function linkRenderer(data, cell, record, rowIndex, columnIndex, store) {
    if  (data != null)  {
        return String.format('<a href="javascript:void(0)" onclick="resellerwindow(\'{0}\')">{1}</a>', record.id, data);
    }
    return data;
}

1 Comment

String.format is a method on the String object in ExtJS. check the docs: dev.sencha.com/deploy/dev/docs/?class=String

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.