We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

put pager on top of grid

Thread ID:

Created:

Updated:

Platform:

Replies:

142312 Jan 28,2019 04:15 AM UTC Jan 29,2019 09:52 AM UTC ASP.NET MVC - EJ 2 5
loading
Tags: Grid
afiqdoherty
Asked On January 28, 2019 04:15 AM UTC

Hi, 

I 've follow sample on how to How to render Pager at the Top of the Grid but it didn't work as expected. I need help to put pager at top page. please find my code below. in the code, .DataBound('dataBound') show error of (too many character in character literal) which produce when we put single quote for "dataBound" value. I've changed to double quote but still not working. 

<div class="control-section" style="width:96%;margin-left:0%;margin-right:1%">
        @Html.EJS().Grid("ProcessFailed").DataSource((IEnumerable<object>)ViewBag.List_ProcessFailed).AllowExcelExport().ShowColumnMenu(true).AllowFiltering().AllowSorting().ToolbarClick("toolbarClick_ProcessFailed").AllowReordering().Columns(col =>
                 {
                     col.Field("RowCount").HeaderText("No.").Visible(false).Width(80).Add();
                     col.Field("InMessageLogID").HeaderText("InMessageLogID").Width(200).Add();
                     col.Field("LoggedDate").HeaderText("LoggedDate").Width(120).Add();
                     col.Field("StatusID").HeaderText("Status Id").Width(200).Add();
                     col.Field("DocumentType").HeaderText("Document Type").Width(200).Add();
                     col.Field("CreatedByID").HeaderText("CreatedByID").Width(200).Add();
                     col.Field("CreatedDate").HeaderText("CreatedDate").Width(180).Add();
                     col.Field("XMLMessage").HeaderText("XMLMessage").Template("#viewXMLMessage").Width(200).Add();
                 }).AllowGrouping(true).AllowResizing(true).AllowPaging().DataBound('dataBound').PageSettings(page => page.PageCount(5).PageSize(10).PageSizes((new string[] { "5", "10", "20", "All" }))).FilterSettings(filter => { filter.Type(Syncfusion.EJ2.Grids.FilterType.Menu); }).Toolbar(new List<string>() { "ExcelExport" }).Render()
    
        <script>
            var initialGridLoad = true;
            function dataBound() {
                if (initialGridLoad) {
                    initialGridLoad = false;
                    var pager = document.getElementsByClassName('e-gridpager')
                    var toolbar = document.getElementsByClassName('e-toolbar')
                    grid.element.insertBefore(pager[0], toolbar[0]);
                }
            }
        </script>
    
    </div>

Pavithra Subramaniyam [Syncfusion]
Replied On January 28, 2019 07:09 AM UTC

Hi Muhammad, 
 
Sorry for the inconvenience caused. 
 
To achieve your requirement you need to get the Grid instance before inserting the pager element in dataBound event. Please refer to the below code example for more information. 
 
[index.cshtml] 
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.dataSource).Columns(col => 
   { 
       col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); 
       .  .  .   
 
   }).AllowPaging().AllowGrouping().DataBound("dataBound").Toolbar(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" }).Render() 
 
<script> 
    var initialGridLoad = true; 
    function dataBound() { 
        if (initialGridLoad) { 
                var topElement; 
                initialGridLoad = false; 
                var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0]; 
                var pager = document.getElementsByClassName('e-gridpager'); 
                if (grid.allowGrouping || grid.toolbar) { 
                    topElement = grid.allowGrouping ? document.getElementsByClassName('e-groupdroparea') : 
                        document.getElementsByClassName('e-toolbar'); 
                } else { 
                    topElement = document.getElementsByClassName('e-gridheader'); 
                } 
                grid.element.insertBefore(pager[0], topElement[0]); 
            } 
        }  
</script> 
 
However, We will made changes in our documentation and these changes will be refreshed in any of our upcoming release. 
 
Please contact us if you need any further assistance. 
 
Regards, 
Pavithra S. 


afiqdoherty
Replied On January 28, 2019 08:20 AM UTC

thank you so much for the reply. that solution works. :)

however, what I need is a little bit different if it is doable. I just need the Pager(drop down 5,10,20,All ) to be on top on the right side. the rest, remain at bottom. means that, Pager will be in same row as Excel Export toolbar. Please refer my picture below.



really appreciate if you can help me to solve this issue. :)))

Actually, the reason is I cannot find solution to maintain the Pager to stay center unless to set manually in .css style(using margin-left). But, the pager will not be in static position if the page numbering(on the left) is expanding. So, it will move the Pager further right. If you know what I mean. Hopefully if you can help me to maintain the Pager stays at center, regardless how long the page numbering is .
 
regards,

afiq

Pavithra Subramaniyam [Syncfusion]
Replied On January 29, 2019 08:33 AM UTC

Hi Muhammad, 
 
We have analyzed your requirement and We suggest you to use the below codes in the “DataBound” event handler of Grid to achieve this requirement. Please refer the code below, 
 
 
   @Html.EJS().Grid("Grid")...DataBound("dataBound")...Render() 
 
   <script> 
       var initialGridLoad = true; 
       function dataBound() { 
        if (initialGridLoad) { 
            initialGridLoad = false; 
            var toolobj = document.getElementsByClassName("e-toolbar")[0].ej2_instances[0];   //Get instance of toolbar 
            toolobj.height = "60px"     //Set the height for the toolbar as required 
            var toolbar = document.getElementsByClassName('e-toolbar-items')[0]; 
            toolbar.classList.add("e-tbar-pos");   //add “e-tbar-pos” class in toolbar element             
            var pagesizedrop = document.getElementsByClassName('e-pagesizes')[0]; 
            pagesizedrop.classList.add("e-toolbar-right");  //add “e-toolbar-right” class to pagesize element 
            //append the page size drop down to toolbar 
           toolbar.appendChild(pagesizedrop); 
        } 
    } 
   </script> 
 
 
Documentations :  
 
Please get back to us if you need further assistance. 
 
Regards, 
Pavithra S. 


afiqdoherty
Replied On January 29, 2019 09:49 AM UTC

Thank you so much Pavithra S. ,  that works :D

Pavithra Subramaniyam [Syncfusion]
Replied On January 29, 2019 09:52 AM UTC

Hi Muhammad,  

Thanks for your update.  

We are happy to hear that the provided information was helpful.  

Please contact us if you need any further assistance. As always, we will be happy to assist you.  

Regards,  
Pavithra S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon