This is a migrated thread and some comments may be shown as answers.

Checkboxes column, PageOnScrolling and GroupBy JS bug

1 Answer 43 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alex
Top achievements
Rank 1
Alex asked on 25 Apr 2012, 02:58 PM
I created a column for checkboxes based on the example described here: http://demos.telerik.com/aspnet-mvc/razor/grid/checkboxesajax
I enable PageOnScrolling
I chose a random column to group by.
I scroll down the grid and get the following exception in Javascript: 'MyPropertyName' is undefined
This is the function that throws the exception.

function anonymous(data) {
var p=[];with(data){p.push('<input type=\'checkbox\' name=\'checkedGroup\' value=\'', MyPropertyName ,'\' />');}return p.join('');
}

I've disabled all javascript that works with the checkbox column on grid events, so the only thing left is the ClientTemplate that creates the checkboxes

columns.Bound(o => o.MyPropertyName)
                   .ClientTemplate("<input type='checkbox' name='checkedGroup' value='<#= MyPropertyName #>' />")
                   .Title("")
                   .Width(40)
                   .HtmlAttributes(new { style = "text-align:center" })
                   .Filterable(false)
                   .Sortable(false)
                   .Groupable(false);

I don't have this exception when there is no GroupBy column.

1 Answer, 1 is accepted

Sort by
0
Alex
Top achievements
Rank 1
answered on 25 Apr 2012, 04:31 PM
I was able to prevent the javascript error by checking for undefined as such:

.ClientTemplate("<input type='checkbox' name='checkedGroup'
                        value='<#= (typeof MyPropertyName !== 'undefined')
                                   ? MyPropertyName
                                   : 0 #>' />"
)

I also had to do this check for all my other client template strings, like 'Yes' / 'No' boolean conversions and Date formatting.  The problem seems to be bigger though.  PageOnScrolling just breaks GroupBy altogether.  The first page displays OK.  But as I scroll down the 2nd page removes the GroupBy formatting in the grid, and adds some blank rows at the bottom (probably why I was getting the javascript errors in the first place).  I'm using TelerikMvcCustomBindingGridHelper so maybe the format of the GroupBy isn't what's expected by the Telerik Grid for PageOnScrolling?
Tags
Grid
Asked by
Alex
Top achievements
Rank 1
Answers by
Alex
Top achievements
Rank 1
Share this question
or