Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Basically, I have two Telerik Grids. Now, I have a checkbox to synchronize the horizontal scroll bar in both the grids and want to disable the synchronization when the checkbox is unchecked. Now, the problem is that as soon as I disable the checkbox i.e. the unbind function is executed, the header bars in both the Telerik Grids doesn't scroll along with the corresponding content in the body in the individual Telerik Grid. I believe the unbind("scroll") breaks the link between the header and the body and I think If I can somehow rebind the header bar in the Telerik grids to the scroll function, the problem would be solved. I tried simply writing the ("selector").bind.("scroll") but that didn't work. Different approaches of solving the problem are welcome.


JavaScript
$(function () {

        $("#checkboxforscrollbarsyncHorizontal").change(function () {
            if (this.checked) {

             // The following code was written to try to rebind the header bar with its scroll event
             //   $('#firstscrollbarlb .t-grid-content').unbind("scroll");
             //   $('#secondscrollbarlb .t-grid-content').unbind("scroll");

         firstscrollbarlb

                $('#firstscrollbarlb .t-grid-content').scroll(function () {
                    var varforfirstscrollbar = $(this).scrollLeft();
                    $('#secondscrollbarlb .t-grid-content').scrollLeft(varforfirstscrollbar);

                });

                $('#secondscrollbarlb .t-grid-content').scroll(function () {

                    var varforsecondscrollbar = $(this).scrollLeft();
                    $('#firstscrollbarlb .t-grid-content').scrollLeft(varforsecondscrollbar);

                });


                });
            }

            else {

                $('#firstscrollbarlb .t-grid-content').unbind("scroll");
                $('#secondscrollbarlb .t-grid-content').unbind("scroll");

            }

        });
    })(checkboxcheckerHorizontal);



Here are the grids
JavaScript
<table>
          <tr>
          <td id="firstscrollbarlb">
            //The Telerik Grid code goes here
          </td>

          <td id="secondscrollbarlb">
           //The Telerik Grid code goes here
         </td> 
        </tr>
       </table>


This is the code for the checkbox.
HTML
<input type="checkbox" id="checkboxforscrollbarsyncHorizontal" onClick="checkboxcheckerHorizontal();"/>Horizontal
Posted
Updated 30-May-13 23:21pm
v2

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900