1

I am using the onCellClick function of Sigma Grid to allow the user to select from a grid and have a form updated with the selected information.

When I try to split the record that is returned from onCellClick (which returns the record associated with the grid row) I get an "Object doesn't support this property or method" pointing to the split line.

onCellClick : function(value, record, cell, row, colNO, rowNO, columnObj, grid){
            var recordCurrent = record;
            var recordSplit = recordCurrent.split(",");
            alert("Participant is " + recordSplit[1]);
            }

If I do an alert showing the unsplit record from the onCellClick event it shows the data I expect.

I am missing something obvious. Any direction you can provide will be appreciated.

2
  • 1
    Check recordCurrent type if it's not string (so, it's not) you cannot split. Commented Jun 22, 2012 at 17:15
  • Even, as Enes mentioned, if you can split it there's still a chance there won't be a value in the 2nd position Commented Jun 22, 2012 at 17:23

2 Answers 2

1

The error you received "Object doesn't support this property or method" would suggest that you are attempting to call .split on something that doesn't have it (not a string).

You should check that your parameters are the types you expect before you work with them:

if (typeof record !== 'string') {
    throw new Error('You must pass a string as the record to onCellClick!');
} else {
    var recordCurrent = record;
    var recordSplit = recordCurrent.split(",");
    alert("Participant is " + recordSplit[1]);
}

Upon further investigation, Sigma grid documentation states that the type of the record parameter is Object or Array, not String.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. It was indeed an object. Converting it to a string using var str = "" + obj; solved the problem. Thank you again.
@hwilliams you're welcome. if the answer helped you and you think it will help other people with a similar problem, you should accept the answer.
0

You should perform two checks:

1) That there is actually a record

2) That the split record has more than one object in it

onCellClick : function(value, record, cell, row, colNO, rowNO, columnObj, grid){
    if (record.length) {
        var recordSplit = record.split(",");
        if (recordSplit.length > 1) {
            alert("Participant is " + recordSplit[1]);
        }
    }
}

Comments

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.