Hi,
I have paging enabled and I would like to add a html button on that same toolbar. I have tried appending like this forum suggested, but it doesn't seem to work ( https://es.infragistics.com/community/forums/t/66059.aspx ). Any suggestions or updates?
Thanks
Hello Edward,
I am glad that you find my suggestion helpful.
Thank you for using Infragistics components.
I modified Tsanna`s sample in order to match your requirement. I am handling rendered event of igGrid to move the pager label from the footer to the header using appendChild and replaceChild in order to keep all of the attached JavaScript objects and events attached to those elements. There are two things that you have to keep in mind for this approach:
1. You have to ensure that the page header is rendered. rendered event can help you with this one. This event is fired after the whole grid widget has been rendered(including headers, footers, etc.)
//Bind after initialization $(document).delegate(".selector", "iggridrendered", function (evt, ui) { var waitForPageHeader = setInterval(function() { $(".ui-iggrid-pagesizedropdowncontainerabove")[0].appendChild($("#grid_pager_label")[0]); $("#grid_pager_label").css("float","left"); $("#grid_pager_label").append("Click"); if($(".ui-iggrid-pagesizedropdowncontainerabove").length > 0) { clearInterval(waitForPageHeader); } }, 10); });
2. The pager is re-rendered every time the page size or page index is changed so the logic should be applied each time any of these events are fired.
//Bind after initialization $(document).delegate(".selector", "iggridpagingpagesizechanged", function (evt, ui) { $(".ui-iggrid-pagesizedropdowncontainerabove")[0].replaceChild($(".ui-iggrid-pager >.ui-iggrid-pagerrecordslabel")[0], $(".ui-iggrid-pagesizedropdowncontainerabove>.ui-iggrid-pagerrecordslabel.ui-iggrid-results")[0]); $("#grid_pager_label").css("float","left"); $("#grid_pager_label").append("Click"); }); //Bind after initialization $(document).delegate(".selector", "iggridpagingpageindexchanged", function (evt, ui) { $(".ui-iggrid-pagesizedropdowncontainerabove")[0].replaceChild($(".ui-iggrid-pager >.ui-iggrid-pagerrecordslabel")[0], $(".ui-iggrid-pagesizedropdowncontainerabove>.ui-iggrid-pagerrecordslabel.ui-iggrid-results")[0]); $("#grid_pager_label").css("float","left"); $("#grid_pager_label").append("Click"); });
//Bind after initialization $(document).delegate(".selector", "iggridpagingpagesizechanged", function (evt, ui) { $(".ui-iggrid-pagesizedropdowncontainerabove")[0].replaceChild($(".ui-iggrid-pager >.ui-iggrid-pagerrecordslabel")[0], $(".ui-iggrid-pagesizedropdowncontainerabove>.ui-iggrid-pagerrecordslabel.ui-iggrid-results")[0]); $("#grid_pager_label").css("float","left"); $("#grid_pager_label").append("Click"); });
//Bind after initialization $(document).delegate(".selector", "iggridpagingpageindexchanged", function (evt, ui) { $(".ui-iggrid-pagesizedropdowncontainerabove")[0].replaceChild($(".ui-iggrid-pager >.ui-iggrid-pagerrecordslabel")[0], $(".ui-iggrid-pagesizedropdowncontainerabove>.ui-iggrid-pagerrecordslabel.ui-iggrid-results")[0]); $("#grid_pager_label").css("float","left"); $("#grid_pager_label").append("Click"); });
In regards to the fact that you are using the MVC wrapper the behavior is the same in both scenarios. If you have any concerns or questions how events are bound you can have a look at our Using Events in IgniteUI topic.
Please have a look at the attached sample and let me know if you need any further assistance with this matter.
So I tested your sample and it works there. However, for some reason I cannot get the same affect with my grid, which is written in Razor. One thing I noticed is that the sample you gave me, "Show x records" appeared on the bottom with the other paging options, but mine is at the top of the grid (where I want the button to be placed). Is it because the grid is rendered first before appending the button?
You may access the grid pager through it's jQuery id selector and append the desired html to it, for example: $("#grid_pager").append("<button>Click</button>"). Attached is a sample for your reference.
If you have further questions, please let me know.
Regards,Tsanna