Hi! I'm working on a project using radgrid, radajaxmanager, radcontextmenu and I've encountered a problem which i cant seem to figure out. The app is ment for tablets so I'm using jquery mobile's taphold event. On taphold i'm showing a radcontextmenu. On taphold I simulate a click on the row (i have a mouse tracking event that sends coordinates of the row I want clicked) so i can take the index number of the row and write it to a hidden field which I use in codebehind to open a radwindow with html query data(based on the data in the row).
The problem is that if I have radajaxmanager enabled that functionality works only the first time. On the second time I get a javascript error that the object is null. I tried alot of things, so in the end I disabled radajaxmanager and found out that everything works out if it's disabled. But ofcourse I like your ajaxmanager so I'd like to use it. So i'm coming to you, the guys that know radajaxmanager best.
And now lets look at the code:
This is my hidden field and my radgrid markup.
This is my radajaxmanager
These are the client settings for radgrid
This is the javascript line that becomes null after only one use if radajaxmanager is on
This is the javascript code that handles the taphold and ajaxstart-end
EDIT: Forgot to add my RadAjaxManager onAjaxRequest:
The problem is that if I have radajaxmanager enabled that functionality works only the first time. On the second time I get a javascript error that the object is null. I tried alot of things, so in the end I disabled radajaxmanager and found out that everything works out if it's disabled. But ofcourse I like your ajaxmanager so I'd like to use it. So i'm coming to you, the guys that know radajaxmanager best.
And now lets look at the code:
This is my hidden field and my radgrid markup.
<
input
type
=
"hidden"
id
=
"radGridClickedRowIndex"
name
=
"radGridClickedRowIndex"
/>
<
telerik:RadGrid
ID
=
"RadGrid_PregledPovprasevanj"
runat
=
"server"
AllowSorting
=
"True"
AllowPaging
=
"True"
PageSize
=
"16"
ShowStatusBar
=
"True"
AllowFilteringByColumn='<%# If(IsNothing(Session("filterGumb")), "false", Session("filterGumb"))%>'
GridLines="None" Height="100%" OnPreRender="RadGrid_PregledPovprasevanj_PreRender" GroupingEnabled="false">
<
ExportSettings
FileName
=
"Izvoz_Povprasevanja"
>
<
Pdf
PageTitle
=
"Povprasevanja"
PageWidth
=
""
/>
</
ExportSettings
>
<
MasterTableView
DataKeyNames
=
"IDPovprasevanja"
AllowMultiColumnSorting
=
"true"
HierarchyLoadMode
=
"Client"
ExpandCollapseColumn-Visible
=
"false"
>
This is my radajaxmanager
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
DefaultLoadingPanelID
=
"RadAjaxLoadingPanel1"
OnAjaxRequest
=
"RadAjaxManager1_AjaxRequest"
EnableAJAX
=
"false"
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid_PregledPovprasevanj"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid_PregledPovprasevanj"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
></
telerik:AjaxUpdatedControl
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadMenu1"
></
telerik:AjaxUpdatedControl
>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadMenu1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadMenu1"
></
telerik:AjaxUpdatedControl
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid_PregledPovprasevanj"
></
telerik:AjaxUpdatedControl
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadWindowManager_DataBrowsers"
></
telerik:AjaxUpdatedControl
>
<
telerik:AjaxUpdatedControl
ControlID
=
"rw_kontakti"
></
telerik:AjaxUpdatedControl
>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
These are the client settings for radgrid
<
ClientSettings
AllowDragToGroup
=
"true"
AllowColumnsReorder
=
"True"
ReorderColumnsOnClient
=
"True"
ColumnsReorderMethod
=
"Reorder"
>
<
Scrolling
/>
<
ClientEvents
OnRowClick
=
"RowContextMenu"
/>
<
Selecting
AllowRowSelect
=
"true"
/>
<
Resizing
/>
</
ClientSettings
>
This is the javascript line that becomes null after only one use if radajaxmanager is on
var
index = eventArgs.get_itemIndexHierarchical();
This is the javascript code that handles the taphold and ajaxstart-end
$(document).mousemove(
function
(e) {
window.x = e.pageX;
window.y = e.pageY;
//console.log(window.x);
});
$(window).load(
function
() {
});
$(document).ready(
function
() {
var
menu = $find(
"<%=RadMenu1.ClientID %>"
)
$(
function
() {
$(
"tr.rgRow"
).bind(
"taphold"
, tapholdHandler);
$(
"tr.rgAltRow"
).bind(
"taphold"
, tapholdHandler);
function
tapholdHandler(e) {
$(document.elementFromPoint(x, y)).click();
menu.showAt(x, y)
}
});
});
$(window).resize(
function
() {
});
function
RowContextMenu(sender, eventArgs) {
var
evt = eventArgs.get_domEvent();
if
(evt.target.tagName ==
"INPUT"
|| evt.target.tagName ==
"A"
) {
return
;
}
var
index = eventArgs.get_itemIndexHierarchical();
// THIS IS WHAT IS NULL AFTER THE FIRST TIME
document.getElementById(
"radGridClickedRowIndex"
).value = index;
}
var
AjaxIsActive =
false
;
function
RequestStart(sender, args) {
if
(!AjaxIsActive) {
AjaxIsActive =
true
;
}
else
{
alert((
typeof
ActiveAJAXMessage ===
'undefined'
) ?
'Wait for ajax to finish'
: ActiveAJAXMessage);
return
false
;
}
document.body.style.cursor =
"wait"
;
//*************************************************************************
if
(args.get_eventTarget().indexOf(
"ExportToExcelButton"
) >= 0 ||
args.get_eventTarget().indexOf(
"ExportToWordButton"
) >= 0 ||
args.get_eventTarget().indexOf(
"ExportToPdfButton"
) >= 0 ||
args.get_eventTarget().indexOf(
"ExportToCsvButton"
) >= 0) {
args.set_enableAjax(
false
);
ResponseEnd();
}
if
(args.get_eventTarget().indexOf(
"btn_Dok_PrikaziDok"
) >= 0) {
args.set_enableAjax(
false
);
ResponseEnd();
}
}
function
ResponseEnd(sender, args) {
AjaxIsActive =
false
;
document.body.style.cursor =
"default"
;
}
EDIT: Forgot to add my RadAjaxManager onAjaxRequest:
Protected
Sub
RadAjaxManager1_AjaxRequest(
ByVal
sender
As
Object
,
ByVal
e
As
AjaxRequestEventArgs)
Handles
RadAjaxManager1.AjaxRequest
If
e.Argument =
"Rebind"
Then
RadGrid_PregledPovprasevanj.MasterTableView.SortExpressions.Clear()
RadGrid_PregledPovprasevanj.MasterTableView.GroupByExpressions.Clear()
RadGrid_PregledPovprasevanj.Rebind()
ElseIf
e.Argument =
"RebindAndNavigate"
Then
RadGrid_PregledPovprasevanj.MasterTableView.SortExpressions.Clear()
RadGrid_PregledPovprasevanj.MasterTableView.GroupByExpressions.Clear()
RadGrid_PregledPovprasevanj.MasterTableView.CurrentPageIndex = RadGrid_PregledPovprasevanj.MasterTableView.PageCount - 1
RadGrid_PregledPovprasevanj.Rebind()
End
If
End
Sub