Fix grid size calculation in javascript widget.