jQWidgets Forums
jQuery UI Widgets › Forums › Grid › grid scrolling issue
Tagged: #jqwidgets-grid, grid, javascript grid, jquery grid
This topic contains 3 replies, has 2 voices, and was last updated by Hristo 8 years, 3 months ago.
-
Authorgrid scrolling issue Posts
-
look at the following example.. i am trying to keep scrollbars in synch with 3 tables..(verticals) everything works.. when group is closed.. but as soon as group is opened.. scrollbars go out of synch.. how can i fix it.. i am using scrollfeedback as suggested
<!DOCTYPE html> <html lang="en"> <head> <title id='Description'>This example shows how to display row details after each grid row.</title> <link rel="stylesheet" href="https://d3j8vrstz9i44d.cloudfront.net/app/assets/js/lib/jqwidgets/styles/jqx.base.rev20170315.css" type="text/css" /> <script type="text/javascript" src="https://d3j8vrstz9i44d.cloudfront.net/app/assets/js/lib/jquery/jquery-1.11.1.rev20170315.js"></script> <script type="text/javascript" src="https://d3j8vrstz9i44d.cloudfront.net/app/assets/js/lib/jqwidgets/jqxcore.rev20170315.js"></script> <script type="text/javascript" src="https://d3j8vrstz9i44d.cloudfront.net/app/assets/js/lib/jqwidgets/jqxdata.rev20170315.js"></script> <script type="text/javascript" src="https://d3j8vrstz9i44d.cloudfront.net/app/assets/js/lib/jqwidgets/jqxbuttons.rev20170315.js"></script> <script type="text/javascript" src="https://d3j8vrstz9i44d.cloudfront.net/app/assets/js/lib/jqwidgets/jqxscrollbar.rev20170315.js"></script> <script type="text/javascript" src="https://d3j8vrstz9i44d.cloudfront.net/app/assets/js/lib/jqwidgets/jqxmenu.rev20170315.js"></script> <script type="text/javascript" src="https://d3j8vrstz9i44d.cloudfront.net/app/assets/js/lib/jqwidgets/jqxgrid.rev20170315.js"></script> <script type="text/javascript" src="https://d3j8vrstz9i44d.cloudfront.net/app/assets/js/lib/jqwidgets/jqxgrid.selection.rev20170315.js"></script> <script type="text/javascript" src="https://d3j8vrstz9i44d.cloudfront.net/app/assets/js/lib/jqwidgets/jqxgrid.grouping.rev20170315.js"></script> <script type="text/javascript" src="https://d3j8vrstz9i44d.cloudfront.net/app/assets/js/lib/jqwidgets/jqxtabs.rev20170315.js"></script> <script type="text/javascript" src="https://d3j8vrstz9i44d.cloudfront.net/app/scripts/demos.rev20170315.js"></script> <style> #jqxgrid .jqx-grid-cell-pinned,#jqxgridChild .jqx-grid-cell-pinned{ background-image: none; } /*#jqxgrid .jqx-grid-group-expand.jqx-icon-arrow-down,#jqxgridChild .jqx-grid-group-expand.jqx-icon-arrow-down, #jqxgrid .jqx-grid-group-collapse.jqx-icon-arrow-right,#jqxgridChild .jqx-grid-group-collapse.jqx-icon-arrow-right{ display:none; } #jqxgrid .jqx-grid-group-cell.jqx-grid-cell-pinned.jqx-grid-group-details-cell,#jqxgridChild .jqx-grid-group-cell.jqx-grid-cell-pinned.jqx-grid-group-details-cell{ display: none; }*/ </style> <script type="text/javascript"> $(document).ready(function () { // prepare the data var data = new Array(); var firstNames = ["Nancy", "Andrew", "Janet", "Margaret", "Steven", "Michael", "Robert", "Laura", "Anne"]; var lastNames = ["Davolio", "Fuller", "Leverling", "Peacock", "Buchanan", "Suyama", "King", "Callahan", "Dodsworth"]; var titles = ["Sales Representative", "Vice President, Sales", "Sales Representative", "Sales Representative", "Sales Manager", "Sales Representative", "Sales Representative", "Inside Sales Coordinator", "Sales Representative"]; var titleofcourtesy = ["Ms.", "Dr.", "Ms.", "Mrs.", "Mr.", "Mr.", "Mr.", "Ms.", "Ms."]; var birthdate = ["08-Dec-48", "19-Feb-52", "30-Aug-63", "19-Sep-37", "04-Mar-55", "02-Jul-63", "29-May-60", "09-Jan-58", "27-Jan-66"]; var hiredate = ["01-May-92", "14-Aug-92", "01-Apr-92", "03-May-93", "17-Oct-93", "17-Oct-93", "02-Jan-94", "05-Mar-94", "15-Nov-94"]; var address = ["507 - 20th Ave. E. Apt. 2A", "908 W. Capital Way", "722 Moss Bay Blvd.", "4110 Old Redmond Rd.", "14 Garrett Hill", "Coventry House", "Miner Rd.", "Edgeham Hollow", "Winchester Way", "4726 - 11th Ave. N.E.", "7 Houndstooth Rd."]; var city = ["Seattle", "Tacoma", "Kirkland", "Redmond", "London", "London", "London", "Seattle", "London"]; var postalcode = ["98122", "98401", "98033", "98052", "SW1 8JR", "EC2 7JR", "RG1 9SP", "98105", "WG2 7LT"]; var country = ["USA", "USA", "USA", "USA", "UK", "UK", "UK", "USA", "UK"]; var homephone = ["(206) 555-9857", "(206) 555-9482", "(206) 555-3412", "(206) 555-8122", "(71) 555-4848", "(71) 555-7773", "(71) 555-5598", "(206) 555-1189", "(71) 555-4444"]; var notes = ["Education includes a BA in psychology from Colorado State University in 1970. She also completed 'The Art of the Cold Call.' Nancy is a member of Toastmasters International.", "Andrew received his BTS commercial in 1974 and a Ph.D. in international marketing from the University of Dallas in 1981. He is fluent in French and Italian and reads German. He joined the company as a sales representative, was promoted to sales manager in January 1992 and to vice president of sales in March 1993. Andrew is a member of the Sales Management Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim Importers Association.", "Janet has a BS degree in chemistry from Boston College (1984). She has also completed a certificate program in food retailing management. Janet was hired as a sales associate in 1991 and promoted to sales representative in February 1992.", "Margaret holds a BA in English literature from Concordia College (1958) and an MA from the American Institute of Culinary Arts (1966). She was assigned to the London office temporarily from July through November 1992.", "Steven Buchanan graduated from St. Andrews University, Scotland, with a BSC degree in 1976. Upon joining the company as a sales representative in 1992, he spent 6 months in an orientation program at the Seattle office and then returned to his permanent post in London. He was promoted to sales manager in March 1993. Mr. Buchanan has completed the courses 'Successful Telemarketing' and 'International Sales Management.' He is fluent in French.", "Michael is a graduate of Sussex University (MA, economics, 1983) and the University of California at Los Angeles (MBA, marketing, 1986). He has also taken the courses 'Multi-Cultural Selling' and 'Time Management for the Sales Professional.' He is fluent in Japanese and can read and write French, Portuguese, and Spanish.", "Robert King served in the Peace Corps and traveled extensively before completing his degree in English at the University of Michigan in 1992, the year he joined the company. After completing a course entitled 'Selling in Europe,' he was transferred to the London office in March 1993.", "Laura received a BA in psychology from the University of Washington. She has also completed a course in business French. She reads and writes French.", "Anne has a BA degree in English from St. Lawrence College. She is fluent in French and German."]; var k = 0; for (var i = 0; i < firstNames.length; i++) { var row = {}; row["firstname"] = firstNames[k]; row["lastname"] = lastNames[k]; row["title"] = titles[k]; row["titleofcourtesy"] = titleofcourtesy[k]; row["birthdate"] = birthdate[k]; row["hiredate"] = hiredate[k]; row["address"] = address[k]; row["city"] = city[k]; row["postalcode"] = postalcode[k]; row["country"] = country[k]; row["homephone"] = homephone[k]; row["notes"] = notes[k]; data[i] = row; k++; } var source = { localdata: data, datatype: "array" }; var initrowdetails = function (index, parentElement, gridElement, datarecord) { } var dataAdapter = new $.jqx.dataAdapter(source); var toThemeProperty = function (className) { return className + " " + className + "-" + "custom"; } var blankRenderer = function (text, group, expanded, data) { //return '<div style="overflow: hidden; text-overflow: ellipsis; padding-bottom: 2px; text-align: left; margin-right: 2px; margin-left: 4px; margin-top: 4px;">' + // data.subItems[0].header + '</div>'; //check if there is mini.. and then get the date part var disp = ''; if(data.subItems[0].hasQty == 'yes'){ return '<div class="optGroupHasQty ' + toThemeProperty('jqx-grid-groups-row') + '" style="position: absolute;"><span>' + disp + '</span></div>'; }else{ return '<div class="' + toThemeProperty('jqx-grid-groups-row') + '" style="position: absolute;"><span>' + disp + '</span></div>'; } }; $("#jqxgrid").jqxGrid( { width: '100%', height: '100%', source: dataAdapter, groupable: true, groupsrenderer: blankRenderer, showrowdetailscolumn:false, groups: ['title'], showgroupsheader:false, showgroupmenuitems:false, scrollmode: 'deferred', scrollfeedback: function(row) { var position = $("#jqxgrid").jqxGrid('scrollposition'); var left = position.left; var top = position.top; $('#jqxgridChild').jqxGrid('scrolloffset', top, left); }, rowdetails: true, rowdetailstemplate: {rowdetails: "<div id='optDetailsMain'style='width:99%;height:100%;border:1px solid red;'>\n\ </div>", rowdetailsheight: 120,rowdetailshidden: true}, initrowdetails: initrowdetails, columns: [ { text: 'First Name', datafield: 'firstname', width: 200 }, { text: 'Last Name', datafield: 'lastname', width: 200 }, { text: 'Title', datafield: 'title', width: 180 }, { text: 'City', datafield: 'city', width: 100 }, { text: 'Country', datafield: 'country'} ] }); var childGroupsrenderer = function (text, group, expanded, data) { //return '<div style="overflow: hidden; text-overflow: ellipsis; padding-bottom: 2px; text-align: left; margin-right: 2px; margin-left: 4px; margin-top: 4px;">' + // data.subItems[0].header + '</div>'; //check if there is mini.. and then get the date part var disp = 'Fri Mar 17 2017(683)'; if(data.subItems[0].hasQty == 'yes'){ return '<div class="optGroupHasQty ' + toThemeProperty('jqx-grid-groups-row') + '" style="position: absolute;"><span>' + disp + '</span></div>'; }else{ return '<div class="' + toThemeProperty('jqx-grid-groups-row') + '" style="position: absolute;"><span>' + disp + '</span></div>'; } }; $("#jqxgridChild").jqxGrid( { width: '100%', height: '100%', source: dataAdapter, scrollmode: 'deferred', showrowdetailscolumn:false, groupable: true, groupindentwidth:1, groupsrenderer: blankRenderer, groups: ['title'], showgroupsheader:false, showgroupmenuitems:false, scrollfeedback: function(row) { var position = $("#jqxgridChild").jqxGrid('scrollposition'); var left = position.left; var top = position.top; $('#jqxgrid').jqxGrid('scrolloffset', top, left); $('#strikeTbl').jqxGrid('scrolloffset', top, left); }, rowdetails: true, rowdetailstemplate: {rowdetails: "<div id='optDetailsMain'style='width:99%;height:100%;border:1px solid red;'>\n\ </div>", rowdetailsheight: 120,rowdetailshidden: true}, initrowdetails: initrowdetails, columns: [ //{ text: 'strike', datafield: '', width: 200,pinned:true }, { text: 'First Name', datafield: 'firstname', width: 200 }, { text: 'Last Name', datafield: 'lastname', width: 200 }, { text: 'Title', datafield: 'title', width: 180 }, { text: 'City', datafield: 'city', width: 100 }, { text: 'Country', datafield: 'country'} ] }); var dataStrike = new Array(); for(var i=0;i<9;i++){ var row = {}; row['strike'] = 100 + i; row['callQty'] = 5; row['putQty'] = 1; row["title"] = titles[i]; dataStrike[i] = row; } var sourceStrike = { localdata: dataStrike, datatype: "array" }; var dataAdapterStrike = new $.jqx.dataAdapter(sourceStrike); $("#strikeTbl").jqxGrid({ width: '100%', height: '100%', scrollmode: 'deferred', source: dataAdapterStrike, scrollbarsize:0, rowdetails: true, showrowdetailscolumn:false, groupable: true, groupindentwidth:1, sortable: false, //editable: true, filterable:false, altrows: true, enablemousewheel:false, showrowdetailscolumn:false, selectionmode:'none', enablerowdetailsindent: true, groupsrenderer: childGroupsrenderer, groups: ['title'], showgroupsheader:false, showgroupmenuitems:false, rowdetailstemplate: {rowdetails: "<div id='optDetailsMain'style='width:99%;height:100%;border:1px solid red;'>\n\ </div>", rowdetailsheight: 120,rowdetailshidden: true}, initrowdetails: initrowdetails, columns:[ //{text:'',datafield:'title',width:0,hidden:true}, {text:'',datafield:'callQty',width:'20%'}, {text:'Strike',datafield:'strike',width:'50%',cellsrenderer:strikePosRenderer}, {text:'',datafield:'putQty',width:'20%'}, ] }); var ary = []; /*$('#jqxgrid').on('rowexpand', function (event){ console.log(event); var args = event.args; var details = args.details; var index = args.rowindex; console.log("inde is :::" + index); $('#jqxgridChild').jqxGrid('showrowdetails', index); $('#strikeTbl').jqxGrid('showrowdetails', index); }); $('#jqxgrid').on('rowcollapse', function (event){ var args = event.args; var index = args.rowindex; console.log("inde is :::" + index); $('#jqxgridChild').jqxGrid('hiderowdetails', index); $('#strikeTbl').jqxGrid('hiderowdetails', index); });*/ $("#strikeTbl").on('groupexpand', function (event) { console.log(event); var args = event.args; var level = args.level; var mainGrp = args.group; var count = $('#jqxgridChild').jqxGrid('getrootgroupscount'); for(var i=0;i<count;i++){ var group = $("#jqxgridChild").jqxGrid('getgroup', i); if(group.group == mainGrp){ $('#jqxgridChild').jqxGrid('expandgroup', i); $('#jqxgrid').jqxGrid('expandgroup', i); break; } } //groupingColumnPatch(true); }); $("#strikeTbl").on('groupcollapse', function (event){ var args = event.args; var level = args.level; var mainGrp = args.group; var count = $('#jqxgridChild').jqxGrid('getrootgroupscount'); for(var i=0;i<count;i++){ var group = $("#jqxgridChild").jqxGrid('getgroup', i); if(group.group == mainGrp){ $('#jqxgridChild').jqxGrid('collapsegroup', i); $('#jqxgrid').jqxGrid('collapsegroup', i); break; } } //groupingColumnPatch(false); }); $("#strikeTbl").on("cellclick", function (event){ event.stopPropagation(); var rowindex = event.args.rowindex; var columnName = event.args.column.datafield; if(columnName === null) return; if(columnName.indexOf('strike') === 0){ if(jQuery.inArray(rowindex, ary) === -1){ console.log('rowindex is :::' + rowindex); $("#strikeTbl").jqxGrid('showrowdetails', rowindex); $('#jqxgridChild').jqxGrid('showrowdetails', rowindex); $('#jqxgrid').jqxGrid('showrowdetails', rowindex); ary.push(rowindex); }else{ $("#strikeTbl").jqxGrid('hiderowdetails', rowindex); $('#jqxgridChild').jqxGrid('hiderowdetails', rowindex); $('#jqxgrid').jqxGrid('hiderowdetails', rowindex); //remove from aray as well var id = jQuery.inArray(rowindex, ary); ary.splice(id,1); } } }); /* $("#jqxgrid").on('mousedown','[id^="horizontalScrollBar"]',function(e){ var position = $("#jqxgrid").jqxGrid('scrollposition'); var left = position.left; var top = position.top; $('#jqxgridChild').jqxGrid('scrolloffset', top, left); }); $("#jqxgrid").on('mouseup','[id^="horizontalScrollBar"]',function(e){ var position = $("#jqx,grid").jqxGrid('scrollposition'); console.log(position); var left = position.left; var top = position.top; $('#jqxgridChild').jqxGrid('scrolloffset', top, left); });*/ }); function strikePosRenderer(row, columnfield, value, defaulthtml, columnproperties){ var div = '<div style="margin-top: 9px;overflow: hidden;padding-bottom: 2px;text-align: center;text-overflow: ellipsis;cursor:pointer;">'; div += '<span style="width:60%;">' + value.toFixed(2) + '</span>'; div += '</div>'; return div; } </script> </head> <body class='default'> <div id='jqxWidget' style="font-size: 13px; font-family: Verdana; float: left;"> <div style="float:left;width:350px;height:250px;"> <div id="jqxgrid"></div> </div> <div style="float:left;width:185px;height:250px;"> <div id="strikeTbl"></div> </div> <div style="float:left;width:350px;height:250px;"> <div id="jqxgridChild" ></div> </div> </div> </body> </html>
expand all groups and then use vertical scrollbar and move. you will see issue..
https://s27.postimg.org/jvv2dvbz7/example.png
you will see first name (andrew ) on right most table is aligned with middle group header column (where it should be just one row below.. as group header is blank in that table.
Hello jahnvi25,
This is expected behavior when use
scrollmode: 'deferred'
– while you change the vertical scrollbar it shows in one container the value of the cell (or row, etc.) of the scrolled position.
You could see this behavior in some of our demos. For example, please, take a look at this demo: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/deferredscrolling.htm?lightBest Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comthen how can i keep 3 tables in synch ? i mean i want to keep scrollbars in synch..i am trying to do this in scrollfeedback (as suggested) but then it is not working with expand of group ??
Hello jahnvi25,
Unfortunately, there is no such option.
I would like to suggest you look at this forum topic:
http://www.jqwidgets.com/community/topic/scroll-event/#post-28187
It is a workaround but could be useful in your case.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.