Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

width calculation fails when upgrading from 8.3 #667

Closed
Alderaic-zz opened this issue May 16, 2013 · 17 comments
Closed

width calculation fails when upgrading from 8.3 #667

Alderaic-zz opened this issue May 16, 2013 · 17 comments

Comments

@Alderaic-zz
Copy link

Hi, upgrading from 8.3 to 8.23, I get consistantly the same error when loading my table:

Uncaught TypeError: Property 'renderer' of object #<Object> is not a function jquery.handsontable.full.js:2665
Handsontable.TableView.applyCellTypeMethod jquery.handsontable.full.js:2665
walkontableConfig.cellRenderer jquery.handsontable.full.js:2514
WalkontableSettings._getSetting jquery.handsontable.full.js:6588
WalkontableSettings.getSetting jquery.handsontable.full.js:6582
Walkontable.getSetting jquery.handsontable.full.js:5613
WalkontableTable._doDraw jquery.handsontable.full.js:6930
WalkontableTable.draw jquery.handsontable.full.js:6841
Walkontable.draw jquery.handsontable.full.js:5581
Handsontable.TableView.render jquery.handsontable.full.js:2653
init jquery.handsontable.full.js:1307
(anonymous function) jquery.handsontable.full.js:2316
p.extend.each jquery-1.8.1.min.js:2
p.fn.p.each jquery-1.8.1.min.js:2
$.fn.handsontable jquery.handsontable.full.js:2301
(anonymous function) functions.js:2556
k jquery-1.8.1.min.js:2
l.fireWith jquery-1.8.1.min.js:2
y jquery-1.8.1.min.js:2
d

This is what I use to load my table,

    $("#example1").handsontable({
    data: clusters,
    minSpareRows: 0,
    startRows: 1,
    startCols: 1,
    rowHeaders: data.products,
    colHeaders: data.headers,
    columns: data.columns,
  currentRowClassName: 'currentRow',
  currentColClassName: 'currentCol',
  autoWrapRow: false
  });

My Data is this:

{
    "clusters": [{
            "product": "Alternate Numbers|Default",
            "product_uid": "4147",
            "profile_uid": "4132",
            "bought": "1000",
            "available": 0,
            "sku_association_uid": "853",
            "locked": 0,
            "2863": "0"
        }, {
            "product": "Attendant Console|Default",
            "product_uid": "4075",
            "profile_uid": "4060",
            "bought": "150",
            "available": 0,
            "sku_association_uid": "858",
            "locked": 0,
            "2863": "0"
        }, {
            "product": "Auto Attendant|Default",
            "product_uid": "4076",
            "profile_uid": "4061",
            "bought": "925",
            "available": 0,
            "sku_association_uid": "857",
            "locked": 0,
            "2863": "0"
        }, {
            "product": "Call Center \/ ACD - Standard|Default",
            "product_uid": "4036",
            "profile_uid": "4021",
            "bought": "150",
            "available": 0,
            "sku_association_uid": "852",
            "locked": 0,
            "2863": "0"
        }, {
            "product": "CommPilot Express|Default",
            "product_uid": "4157",
            "profile_uid": "4142",
            "bought": "6000",
            "available": 0,
            "sku_association_uid": "860",
            "locked": 0,
            "2863": "0"
        }, {
            "product": "Consumer Mobility|Mixed Model",
            "product_uid": "4080",
            "profile_uid": "4065",
            "bought": "1000",
            "available": 0,
            "sku_association_uid": "862",
            "locked": 0,
            "2863": "0"
        }, {
            "product": "Operating System|Default",
            "product_uid": "4041",
            "profile_uid": "4026",
            "bought": "10000",
            "available": 0,
            "sku_association_uid": "863",
            "locked": 0,
            "2863": "0"
        }, {
            "product": "Outlook Integration|Default",
            "product_uid": "4098",
            "profile_uid": "4083",
            "bought": "10000",
            "available": 0,
            "sku_association_uid": "849",
            "locked": 0,
            "601": "0",
            "2863": "0"
        }, {
            "product": "Premium Enterprise|Mixed Model",
            "product_uid": "4033",
            "profile_uid": "4018",
            "bought": "2500",
            "available": 0,
            "sku_association_uid": "861",
            "locked": 0,
            "601": "3500",
            "2863": "0"
        }, {
            "product": "Premium Residential \/ SOHO|Mixed Model",
            "product_uid": "4062",
            "profile_uid": "4047",
            "bought": "2000",
            "available": 0,
            "sku_association_uid": "859",
            "locked": 0,
            "2863": "2000"
        }, {
            "product": "Remote Office|Default",
            "product_uid": "4137",
            "profile_uid": "4122",
            "bought": "1000",
            "available": 0,
            "sku_association_uid": "866",
            "locked": 0,
            "2863": "0"
        }, {
            "product": "Shared Call Appearance|Default",
            "product_uid": "4136",
            "profile_uid": "4121",
            "bought": "2000",
            "available": 0,
            "sku_association_uid": "856",
            "locked": 0,
            "2863": "0",
            "5620": "0"
        }, {
            "product": "Standard Enterprise|Mixed Model",
            "product_uid": "4064",
            "profile_uid": "4049",
            "bought": "3000",
            "available": 0,
            "sku_association_uid": "865",
            "locked": 0,
            "2863": "0"
        }, {
            "product": "Standard Residential \/ SOHO|Mixed Model",
            "product_uid": "4034",
            "profile_uid": "4019",
            "bought": "208000",
            "available": 0,
            "sku_association_uid": "855",
            "locked": 0,
            "2863": "20000"
        }, {
            "product": "Unified Messaging - Fax|Default",
            "product_uid": "4073",
            "profile_uid": "4058",
            "bought": "7500",
            "available": 0,
            "sku_association_uid": "6694",
            "locked": 0,
            "2863": "0"
        }, {
            "product": "Unified Messaging - Standard|Default",
            "product_uid": "4039",
            "profile_uid": "4024",
            "bought": "151000",
            "available": 0,
            "sku_association_uid": "868",
            "locked": 0,
            "2863": "0"
        }, {
            "product": "Web Conferencing|Default",
            "product_uid": "4091",
            "profile_uid": "4076",
            "bought": "1000002",
            "available": 0,
            "sku_association_uid": "848",
            "locked": 0,
            "2863": "0"
        }
    ],
    "customer_id": "C10099",
    "products": ["Alternate Numbers|Default", "Attendant Console|Default", "Auto Attendant|Default", "Call Center \/ ACD - Standard|Default", "CommPilot Express|Default", "Consumer Mobility|Mixed Model", "Operating System|Default", "Outlook Integration|Default", "Premium Enterprise|Mixed Model", "Premium Residential \/ SOHO|Mixed Model", "Remote Office|Default", "Shared Call Appearance|Default", "Standard Enterprise|Mixed Model", "Standard Residential \/ SOHO|Mixed Model", "Unified Messaging - Fax|Default", "Unified Messaging - Standard|Default", "Web Conferencing|Default"],
    "headers": ["<br>Bought Qte", "<br>Available", "<br>Locked", "Production<br>AS Cluster 1", "Production<br>AS Cluster 2", "Production<br>AS Cluster 3", "Production<br>AS Cluster 4"],
    "columns": [{
            "data": "bought",
            "type": {
                "renderer": "myReadonlyRenderer"
            },
            "readOnly": true
        }, {
            "data": "available",
            "type": {
                "renderer": "myReadonlyRenderer"
            },
            "readOnly": true,
            "remainerColumn": true
        }, {
            "data": "locked",
            "type": {
                "renderer": "myReadonlyRenderer"
            },
            "readOnly": true
        }, {
            "data": 601,
            "type": {
                "renderer": "myReadonlyRenderer"
            }
        }, {
            "data": 2863,
            "type": {
                "renderer": "myReadonlyRenderer"
            }
        }, {
            "data": 4993,
            "type": {
                "renderer": "myReadonlyRenderer"
            }
        }, {
            "data": 5620,
            "type": {
                "renderer": "myReadonlyRenderer"
            }
        }
    ]
}

I was able to display some stuff by changing the width but then it only displays headers and the first row before giving me that error again.

I went through the changelog a couple times, but I cannot find what changed except in 8.3 but that's what I was already on.

@setthase
Copy link

Maybe you should have:

    $("#example1").handsontable({
        data: data.clusters,
    ...

@Alderaic-zz
Copy link
Author

sorry I have this a couple lines higher:

clusters =data.clusters
as I access it after as well,
as I said it works just fine with 8.3

@setthase
Copy link

       {
            "data": 5620,
            "type": {
                "renderer": "myReadonlyRenderer"
            }
        }

Are you sure that you have registered myReadonlyRenderer into handsontable?

@Alderaic-zz
Copy link
Author

yes this is my actual renderer:

function myReadonlyRenderer(instance, td, row, col, prop, value, cellProperties) {
  Handsontable.TextCell.renderer.apply(this, arguments);
  //use the built-in text cell renderer

  var readOnlyClass="";
  if (cellProperties.readOnly) {
    readOnlyClass = 'dimmed ';
    //apply "dimmed" class if cell has readOnly property
  }
  if (parseInt(value, 10) < 0) { //if row contains negative number
    td.className = 'negative '+readOnlyClass; //add class "negative"
  }else if(isNaN(value)){
    if (cellProperties.remainerColumn){
      td.className = 'negative '+readOnlyClass; //add class "negative"
    }
  }  else if (parseInt(value, 10) > 0) {
    if (cellProperties.remainerColumn){
      td.className = 'positive '+readOnlyClass;
    } else {
      td.className = readOnlyClass;
    }
  }
  else {
    if (cellProperties.remainerColumn){
      td.className = 'zero '+readOnlyClass;
    } else {
      td.className = readOnlyClass;
    }
  }
}

relatively similar to one of the samples on the website.

css is in as well:

.dimmed {
  font-style: italic;
  color: #777;
  white-space: nowrap;
}
.negative {
  color: red;
}
.zero {
  color: green;
}
.positive {
  color: orange;
}

For a second I thought it could be because of the css but then the js doesnt care about it, it only assigns a class.. quite puzzled by this error, tried to add some breakpoints, I truly cannot find it.

@warpech
Copy link
Member

warpech commented May 16, 2013

Shouldn't it be:

       {
            "data": 5620,
            "type": {
                "renderer": myReadonlyRenderer
            }
        }

?

What errors do you see in the console?

@setthase
Copy link

I think that you should add function reference in this code fragment I cite above and not string.

@Alderaic-zz
Copy link
Author

@warpech I see this: Uncaught TypeError: Property 'renderer' of object # is not a function jquery.handsontable.full.js:2665
Handsontable.TableView.applyCellTypeMethod jquery.handsontable.full.js:2665

@codename- : good suggestion, I will try that

@warpech
Copy link
Member

warpech commented May 16, 2013

Maybe adding this line above the constructor will work:

  Handsontable.cellTypes.myReadonlyRenderer = {
    renderer: myReadonlyRenderer
  }

This will alias myReadonlyRenderer function into "myReadonlyRenderer" string, so you can continu

@setthase
Copy link

^up - but then you need also change:

"type": {
                "renderer": 'myReadonlyRenderer'
            }

for this:

"type": 'myReadonlyRenderer'

@Alderaic-zz
Copy link
Author

I will try this, as I cannot remove quotes arround myReadonlyRender (loaded through json call)

@Alderaic-zz
Copy link
Author

and that was it, thanks guys!
not sure what line should be corrected if any, in case someone gets into the same situation?

@Alderaic-zz
Copy link
Author

Thanks very much for the help, I can finally use the fixed columns now ;)

@setthase
Copy link

Non of them should be corrected.

You should use API as is in specification written :)

@warpech
Copy link
Member

warpech commented May 16, 2013

I will add some error message that can help isolate the problem

@Alderaic-zz
Copy link
Author

thanks,

I was using this as a base:
http://handsontable.com/demo/conditional.html

maybe mention on this page that loading the renderer through a ajax/json
load should be done as you showed me,

On Thu, May 16, 2013 at 3:03 PM, Marcin Warpechowski <
notifications@github.com> wrote:

I will add some error message that can help isolate the problem


Reply to this email directly or view it on GitHubhttps://github.com//issues/667#issuecomment-18022099
.

@setthase
Copy link

@Alderaic - this information could be helpful 👍

@warpech
Copy link
Member

warpech commented May 21, 2013

In version 0.9.0, I updated the http://handsontable.com/demo/conditional.html example with you advice.

Also wiki Options page was updated about renderer and editor options.

Thanks for this report!

@warpech warpech closed this as completed May 21, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants