I currently have a js function that binds onchange to onbeforeunload or a confirmbox only if there are changes on the grid.
I am trying to select the footer paging anchors so that it doesn't trigger for confirm or onbeforeunload. The user should select the numeric paging regardless if there are changes or not on the grid.
There is no ID or class name on the anchors so I'm having trouble accessing it.
Thanks in advance.
RadGrid properties:
<telerik:RadGrid
runat="server"
ID="DataGridFooItems"
AllowSorting="true"
AutoGenerateColumns="false"
EnableViewState="True"
GridLines="Vertical"
AllowPaging="True"
PagerStyle-Mode="NumericPages">
<MasterTableView
AllowPaging="true"
DataKeyNames="foopersonID,fooItemID"
AllowAutomaticDeletes="true"
CommandItemDisplay="None"
NoMasterRecordsText="" >
This is what the .aspx generates below:
<TFOOT>
<TR class=rgPager>
<TD colSpan=20>
<TABLE style="WIDTH: 100%" border=0 cellSpacing=0>
<TBODY>
<TR>
<TD class="rgPagerCell NumericPages">
<DIV class="rgWrap rgNumPart">
<A class=rgCurrentPage onclick="returnfalse;"href="javascript:__doPostBack('ctl00$ph$FOO$rgItems$ctl00$ctl03$ctl01$ctl02','')"><SPAN>1</SPAN></A><A
href="javascript:__doPostBack('ctl00$ph$FOO$rgItems$ctl00$ctl03$ctl01$ctl04','')"><SPAN>2</SPAN></A><A
href="javascript:__doPostBack('ctl00$ph$FOO$rgItems$ctl00$ctl03$ctl01$ctl06','')"><SPAN>3</SPAN></A><A
href="javascript:__doPostBack('ctl00$ph$FOO$rgItems$ctl00$ctl03$ctl01$ctl08','')"><SPAN>4</SPAN></A><A
href="javascript:__doPostBack('ctl00$ph$FOO$rgItems$ctl00$ctl03$ctl01$ctl10','')"><SPAN>5</SPAN></A><A
href="javascript:__doPostBack('ctl00$ph$FOO$rgItems$ctl00$ctl03$ctl01$ctl12','')"><SPAN>6</SPAN></A><A
href="javascript:__doPostBack('ctl00$ph$FOO$rgItems$ctl00$ctl03$ctl01$ctl14','')"><SPAN>7</SPAN></A><A
href="javascript:__doPostBack('ctl00$ph$FOO$rgItems$ctl00$ctl03$ctl01$ctl16','')"><SPAN>8</SPAN></A><A
href="javascript:__doPostBack('ctl00$ph$FOO$rgItems$ctl00$ctl03$ctl01$ctl18','')"><SPAN>9</SPAN></A><A
href="javascript:__doPostBack('ctl00$ph$FOO$rgItems$ctl00$ctl03$ctl01$ctl20','')"><SPAN>10</SPAN></A><A
href="javascript:__doPostBack('ctl00$ph$FOO$rgItems$ctl00$ctl03$ctl01$ctl22','')"><SPAN>...</SPAN></A>
</DIV></TD></TR></TBODY></TABLE></TD></TR></TFOOT>
UPDATE: Answer!
Found it! with some research and tweaking of a similar Telerik Solution.
I composed this:
function preventPromptOnFooter() {
var pagerCell = $('[class="rgPagerCell NumericPages"]')
var anchors = $(pagerCell).find('a');
for (var i = 0; i < anchors.length; i++) {
if (anchors[i].className != "rgCurrentPage" && anchors[i].href.indexOf("javascript:__doPostBack") > -1) {
var clickScript = anchors[i].attributes["onclick"].value;
anchors[i].onclick = disableOnbeforeUnloadForFooter;
}
}
function disableOnbeforeUnloadForFooter() {
window.onbeforeunload = null;
}
}
Found it! with some research and tweaking of a similar Telerik Solution.
I composed this:
function preventPromptOnFooter() {
var pagerCell = $('[class="rgPagerCell NumericPages"]')
var anchors = $(pagerCell).find('a');
for (var i = 0; i < anchors.length; i++) {
if (anchors[i].className != "rgCurrentPage" && anchors[i].href.indexOf("javascript:__doPostBack") > -1) {
var clickScript = anchors[i].attributes["onclick"].value;
anchors[i].onclick = disableOnbeforeUnloadForFooter;
}
}
function disableOnbeforeUnloadForFooter() {
window.onbeforeunload = null;
}
}