I am having issues with Paging within a Radgrid. I have specified a PageStyle Mode="Advanced". If I change the mode to NextPrevNumericAndAdvanced or any other type with the Go To First, Previous, Next and Go To Last page buttons these will work fine but in Advanced mode the Textbox to change the page and pagesize do not work. It causes a postback on the page but does not update the grid data or the paging/pagesize textbox(es). I am using NeedDataSource for my grid binding and when I break the code during this procedure the CurrentPageIndex is always set to 0. Any help would be great.
5 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 30 May 2014, 06:28 AM
Hi Brian,
This is not an expected behavior, and without your code its hard to replicate the issue. Below is a sample code snippet in which paging works fine. Provide your full code for further help.
ASPX:
C#:
Thanks,
Princy
This is not an expected behavior, and without your code its hard to replicate the issue. Below is a sample code snippet in which paging works fine. Provide your full code for further help.
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateColumns
=
"false"
AllowPaging
=
"true"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
>
<
PagerStyle
Mode
=
"Advanced"
/>
<
MasterTableView
>
<
Columns
>
<
telerik:GridEditCommandColumn
>
</
telerik:GridEditCommandColumn
>
<
telerik:GridBoundColumn
DataField
=
"OrderID"
HeaderText
=
"OrderID"
UniqueName
=
"OrderID"
/>
<
telerik:GridBoundColumn
DataField
=
"ShipName"
HeaderText
=
"ShipName"
UniqueName
=
"ShipName"
/>
<
telerik:GridTemplateColumn
DataField
=
"ShipCountry"
>
<
ItemTemplate
>
<%#Eval("ShipCountry")%>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
C#:
protected
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = GetDataTable(
"SELECT * FROM Orders"
);
}
public
DataTable GetDataTable(
string
query)
{
String ConnString = ConfigurationManager.ConnectionStrings[
"ConnectionString"
].ConnectionString;
SqlConnection conn =
new
SqlConnection(ConnString);
SqlDataAdapter adapter =
new
SqlDataAdapter();
adapter.SelectCommand =
new
SqlCommand(query, conn);
DataTable myDataTable =
new
DataTable();
conn.Open();
try
{
adapter.Fill(myDataTable);
}
finally
{
conn.Close();
}
return
myDataTable;
}
Thanks,
Princy
0

Brian
Top achievements
Rank 1
answered on 30 May 2014, 02:45 PM
ASPX:
<
telerik:RadAjaxManager
ID
=
"am"
runat
=
"server"
ClientEvents-OnRequestStart
=
"mngRequestStarted"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"gInventoryMobile"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"gInventorymobile"
LoadingPanelID
=
"RadAjaxLoadingPanel"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"btnExport"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"gInventorymobile"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"btnExport"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"gGroupUpdate"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"gGroupUpdate"
LoadingPanelID
=
"RadAjaxLoadingPanel"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
<
ClientEvents
OnRequestStart
=
"mngRequestStarted"
/>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel"
runat
=
"server"
BackColor
=
"White"
Height
=
"75px"
Width
=
"75px"
Transparency
=
"25"
>
<
div
style
=
"margin-top: 20px;"
>
<
img
src='<%= Application("APPLICATIONPATH") %>/img/loader.gif' style="border: 0;" /><
br
/>
<
span
style
=
"font-size: 18px; font-weight: bold; display: block; margin-top: 10px; color: #333333;"
>Loading</
span
>
</
div
>
</
telerik:RadAjaxLoadingPanel
>
<
div
class
=
"PageSection full"
style
=
"border: none; background: none;"
>
<
h1
>iPad Management</
h1
>
<
div
class
=
"content"
>
<
telerik:RadGrid
ID
=
"gInventoryMobile"
runat
=
"server"
EnableLinqExpressions
=
"false"
AllowMultiRowSelection
=
"true"
AutoGenerateColumns
=
"false"
AllowFilteringByColumn
=
"True"
AllowSorting
=
"true"
GridLines
=
"None"
PageSize
=
"25"
CssClass
=
"GridInContent"
AllowPaging
=
"true"
AllowCustomPaging
=
"true"
VirtualItemCount
=
"100000"
>
<
MasterTableView
NoDetailRecordsText
=
"No Records"
DataKeyNames
=
"InventoryId, InventoryMobileDetailId"
CommandItemDisplay
=
"Bottom"
>
<
PagerStyle
Mode
=
"NextPrevNumericAndAdvanced"
Position
=
"Bottom"
/>
<
CommandItemTemplate
>
<
div
>
<
asp:LinkButton
ID
=
"btnExport"
runat
=
"server"
OnClick
=
"btnExport_Click"
CssClass
=
"buttonAction left"
Text
=
"Export to Excel"
/>
<
asp:LinkButton
ID
=
"btnAdd"
runat
=
"server"
CssClass
=
"buttonAction right"
Text
=
"Add to Group Update"
ClientIDMode
=
"Static"
/>
</
div
>
</
CommandItemTemplate
>
<
Columns
>
<
telerik:GridClientSelectColumn
UniqueName
=
"ClientSelectColumn"
/>
<
telerik:GridTemplateColumn
DataField
=
"InventoryMobileDetailId"
UniqueName
=
"AlertFilter"
>
<
FilterTemplate
>
<
div
id
=
"dvAlertFilter"
></
div
>
<
telerik:RadScriptBlock
runat
=
"server"
ID
=
"sb"
>
<
script
type
=
"text/javascript"
>
var basePath = "<%= Request.Url.AbsolutePath%>";
function getCurrentFilter() {
var currentFilter = '<%# TryCast(Container, GridItem).OwnerTableView.GetColumn("AlertFilter").CurrentFilterFunction%>';
return currentFilter;
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
<
ItemTemplate
>
<
asp:Image
ID
=
"iAlert"
runat
=
"server"
ImageUrl
=
"~/IMG/icons/Alert_Enabled.ico"
Visible='<%# Eval("InventoryMobileDetailId") <= 0 %>' />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"iPadInventoryColumnFilter"
DataField
=
"iPadInventoryColumnFilter"
HeaderText
=
"iPad Inventory"
Display
=
"true"
AllowFiltering
=
"true"
>
<
ItemTemplate
>
<
ul
class
=
"gridItem"
>
<
li
class
=
"formNumber"
id
=
"Bar_Code"
><%# Eval("Bar_Code")%></
li
>
<
li
class
=
"inventoryID"
id
=
"InventoryId"
><
label
>Inventory ID:</
label
> <%# Eval("InventoryId")%></
li
>
<
li
class
=
"lifetimeID"
id
=
"LifeTimeId"
><
label
>Lifetime ID:</
label
> <%# Eval("LifetimeID")%></
li
>
</
ul
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"Title"
DataField
=
"Title"
Display
=
"true"
AllowFiltering
=
"true"
HeaderText
=
"iPad Item Title"
/>
<
telerik:GridTemplateColumn
UniqueName
=
"SectionVisibility"
HeaderText
=
"Section Visibility"
DataField
=
"SectionVisibilityColumnFilter"
>
<
FilterTemplate
>
<
asp:TextBox
ID
=
"tSectionVisibilityFilter"
runat
=
"server"
AutoPostBack
=
"true"
OnTextChanged
=
"tSectionVisibilityFilter_OnTextChanged"
OnPreRender
=
"tSectionVisibilityFilter_PreRender"
></
asp:TextBox
>
</
FilterTemplate
>
<
ItemTemplate
>
<
asp:Repeater
ID
=
"rMobileApp"
runat
=
"server"
DataSource='<%# Eval("MobileAppSectionCollection")%>'>
<
ItemTemplate
>
<
table
class='gridItem appSectVis-<%# GetApplicationType(Eval("MobileAppId"))%>' cellpadding="0" cellspacing="0">
<
tr
>
<
td
class='indicator-<%# GetApplicationType(Eval("MobileAppId"))%>'><%# GetApplicationType(Eval("MobileAppId"))%></
td
>
<
td
>
<
asp:Repeater
ID
=
"Repeater1"
runat
=
"server"
DataSource='<%# Eval("MobileAppSectionSubSectionCollection")%>'>
<
ItemTemplate
>
<
ul
>
<
span
class
=
"section"
><%# Eval("MobileAppSectionName")%></
span
>
<
span
class
=
"subSection"
<%# IIf(Eval("MobileAppSubSectionName").ToString() = String.Empty, "
style
=
'display:none;'
", "")%>> > <%# Eval("MobileAppSubSectionName")%></
span
>
</
ul
>
</
ItemTemplate
>
</
asp:Repeater
>
</
td
>
</
tr
>
</
table
>
</
ItemTemplate
>
<
SeparatorTemplate
><
br
/></
SeparatorTemplate
>
</
asp:Repeater
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"AttachmentTypes"
HeaderText
=
"Attachments"
DataField
=
"AttachmentTypes"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"cAttachmentFilter"
runat
=
"server"
OnSelectedIndexChanged
=
"FilterCombo_SelectedIndexChanged"
AutoPostBack
=
"true"
OnPreRender
=
"cAttachmentFilter_PreRender"
AppendDataBoundItems
=
"true"
DataSource='<%# GetAttachmentList()%>' CheckBoxes="true" EnableCheckAllItemsCheckBox="true"></
telerik:RadComboBox
>
</
FilterTemplate
>
<
ItemTemplate
>
<
telerik:RadListView
ID
=
"lAttachments"
runat
=
"server"
DataSource='<%# GetAttachmentCollection(Eval("InventoryID")) %>' ItemPlaceholderID="ItemPlaceholder">
<
LayoutTemplate
>
<
ul
class
=
"gridItem attachmentsIcons"
>
<
div
id
=
"ItemPlaceholder"
runat
=
"server"
></
div
>
</
ul
>
</
LayoutTemplate
>
<
ItemTemplate
>
<
li
><
a
href
=
"<%# Eval("
FullFilePath").ToString.Substring(1)%>" target="_blank" class='<%# Eval("AttachmentClass") %>'><%# GetAttachmentDisplay(Eval("AttachmentClass")) %></
a
></
li
>
</
ItemTemplate
>
</
telerik:RadListView
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
AllowFiltering
=
"false"
>
<
ItemTemplate
>
<
asp:LinkButton
ID
=
"lbEdit"
OnClick
=
"lbEdit_Click"
runat
=
"server"
CommandName
=
"iEdit"
Text
=
"Edit"
CssClass
=
"buttonAction"
CommandArgument='<%# Eval("InventoryId")%>'></
asp:LinkButton
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"InventoryMobileDetailId"
DataField
=
"InventoryMobileDetailId"
Display
=
"false"
/>
<
telerik:GridBoundColumn
UniqueName
=
"LifeTimeID"
DataField
=
"LifetimeID"
Display
=
"false"
HeaderText
=
"LifeTime ID"
/>
<
telerik:GridBoundColumn
UniqueName
=
"InventoryId"
DataField
=
"InventoryId"
Display
=
"false"
HeaderText
=
"Inventory ID"
/>
<
telerik:GridBoundColumn
UniqueName
=
"Bar_Code"
DataField
=
"Bar_Code"
Display
=
"false"
HeaderText
=
"Form Number"
/>
<
telerik:GridBoundColumn
UniqueName
=
"MobileApp"
DataField
=
"MobileAppSectionCollection(0).MobileAppName"
Display
=
"false"
HeaderText
=
"Mobile App"
/>
<
telerik:GridBoundColumn
UniqueName
=
"MobileAppId"
DataField
=
"MobileAppSectionCollection(0).MobileAppID"
Display
=
"false"
HeaderText
=
"Mobile App ID"
/>
<
telerik:GridTemplateColumn
UniqueName
=
"SectionVisibilityGU"
HeaderText
=
"Section Visibility"
DataField
=
"MobileAppLocationCollection.MobileAppName"
Display
=
"false"
>
<
ItemTemplate
>
<
asp:Repeater
ID
=
"rMobileAppGU"
runat
=
"server"
DataSource='<%# Eval("MobileAppSectionCollection")%>'>
<
ItemTemplate
>
<
asp:Repeater
ID
=
"rMobileApp2GU"
runat
=
"server"
DataSource='<%# Eval("MobileAppSectionSubSectionCollection")%>'>
<
ItemTemplate
>
<%# (TryCast(Container.Parent.Parent, RepeaterItem)).DataItem.MobileAppName %> >
<%# Eval("MobileAppSectionName")%>
<
span
<%# IIf(Eval("MobileAppSubSectionName").ToString() = String.Empty, "
style
=
'display:none;'
", "")%>> > <%# Eval("MobileAppSubSectionName")%></
span
>
</
ItemTemplate
>
<
SeparatorTemplate
><
br
/></
SeparatorTemplate
>
</
asp:Repeater
>
</
ItemTemplate
>
<
SeparatorTemplate
><
br
/></
SeparatorTemplate
>
</
asp:Repeater
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"True"
></
Selecting
>
<
ClientEvents
OnGridCreated
=
"getInventoryMobileGridObject"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
</
div
>
</
div
>
<
div
class
=
"clear"
>
</
div
>
<
div
class
=
"pageBottomFull"
>
</
div
>
<
div
class
=
"Spacer-15"
>
</
div
>
<
div
class
=
"PageSection full"
style
=
"border: none; background: none;"
id
=
"dvGroupUpdate"
>
<
label
id
=
"dvStatusMessage"
class
=
"alert"
></
label
>
<
div
>
<
h1
>iPad Application Group Update</
h1
>
</
div
>
<
div
class
=
"content"
>
<
telerik:RadGrid
ID
=
"gGroupUpdate"
runat
=
"server"
AutoGenerateColumns
=
"false"
CssClass
=
"GridInContent"
>
<
MasterTableView
CommandItemDisplay
=
"Bottom"
>
<
CommandItemTemplate
>
<
table
cellpadding
=
"0"
cellspacing
=
"4"
>
<
tr
>
<
td
style
=
"width:10%;"
>
<
asp:LinkButton
ID
=
"btnClear"
runat
=
"server"
CssClass
=
"buttonAction left"
Text
=
"Clear"
/>
</
td
>
<
td
style
=
"text-align:right;"
>
<
ul
class
=
"horizontal-list"
>
<
li
>
<
select
id
=
"ddlMobileApps"
name
=
"ddlMobileApps"
style
=
"width:200px; max-width:200px"
></
select
>
<
span
style
=
"color: red;"
>*</
span
>
</
li
>
<
li
>
<
select
id
=
"ddlMobileAppSections"
name
=
"ddlMobileAppSections"
style
=
"width:200px; max-width:200px"
></
select
>
<
span
style
=
"color: red;"
>*</
span
>
</
li
>
<
li
>
<
select
id
=
"ddlMobileAppSubSections"
name
=
"ddlMobileAppSubSections"
style
=
"width:200px; max-width:200px"
></
select
>
</
li
>
<
li
>
<
asp:LinkButton
ID
=
"btnAddAppSectionData"
runat
=
"server"
CssClass
=
"buttonAction"
Text
=
"Add"
OnClientClick
=
"confirmGroupUpdateKeepInGrid('Add'); return false;"
/>
<
asp:LinkButton
ID
=
"btnRemoveAppSectionData"
runat
=
"server"
CssClass
=
"buttonAction"
Text
=
"Remove"
OnClientClick
=
"confirmGroupUpdateKeepInGrid('Remove'); return false;"
/>
</
li
>
</
ul
>
</
td
>
</
tr
>
<
tr
>
<
td
>
</
td
>
<
td
>
<
ul
class
=
"horizontal-list"
>
<
li
>
<
select
id
=
"ddlResweepTarget"
name
=
"ddlResweepTarget"
style
=
"width:200px; max-width:200px"
>
<
option
value
=
""
> -Select Resweep Target- </
option
>
<
option
value
=
"thumbnail"
>Thumbnail</
option
>
<
option
value
=
"sample"
>Sample</
option
>
<
option
value
=
"thumbnail,sample"
>Sample and Thumbnail</
option
>
</
select
>
</
li
>
<
li
>
<
asp:LinkButton
ID
=
"btnResweep"
runat
=
"server"
CssClass
=
"buttonAction"
Text
=
"Resweep"
OnClientClick
=
"onResweepClick(); return false;"
/>
</
li
>
</
ul
>
</
td
>
</
tr
>
</
table
>
</
CommandItemTemplate
>
<
Columns
>
<
telerik:GridBoundColumn
UniqueName
=
"InventoryId"
DataField
=
"InventoryId"
Display
=
"false"
/>
<
telerik:GridBoundColumn
UniqueName
=
"InventoryMobileDetailId"
DataField
=
"InventoryMobileDetailId"
Display
=
"false"
/>
<
telerik:GridBoundColumn
DataField
=
"Bar_Code"
HeaderText
=
"Form Number"
UniqueName
=
"Bar_Code"
/>
<
telerik:GridBoundColumn
DataField
=
"Title"
HeaderText
=
"iPad Item Title"
UniqueName
=
"Title"
/>
<
telerik:GridBoundColumn
DataField
=
"MobileApp"
HeaderText
=
"Mobile Apps"
UniqueName
=
"MobileApp"
Display
=
"false"
/>
<
telerik:GridBoundColumn
DataField
=
"SectionVisibility"
HeaderText
=
"Section Visibility"
UniqueName
=
"SectionVisibility"
/>
<
telerik:GridBoundColumn
UniqueName
=
"MobileAppId"
DataField
=
"MobileAppId"
Display
=
"false"
/>
<
telerik:GridButtonColumn
CommandName
=
"Remove"
ButtonType
=
"LinkButton"
ItemStyle-CssClass
=
"item"
FooterStyle-CssClass
=
"footer"
HeaderStyle-CssClass
=
"header"
ButtonCssClass
=
"button"
Text
=
"Remove"
/>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
EnablePostBackOnRowClick
=
"false"
>
<
ClientEvents
OnCommand
=
"gGroupUpdate_Command"
OnGridCreated
=
"getGroupUpdateGridObject"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
</
div
>
</
div
>
<
div
class
=
"clear"
>
</
div
>
<
div
class
=
"pageBottomFull"
>
</
div
>
<
div
class
=
"Spacer-15"
>
</
div
>
<
div
class
=
"PageSection full"
id
=
"gvChangeHistory"
>
<
div
>
<
h1
>Change History</
h1
>
</
div
>
<
div
class
=
"content"
>
<
veritas:SiteHistoryInventory
ID
=
"SiteHistoryGridData"
ShowMobilePiecesOnly
=
"True"
InventoryID
=
"-1"
runat
=
"server"
/>
</
div
>
</
div
>
<
div
class
=
"clear"
>
</
div
>
<
div
class
=
"pageBottomFull"
>
</
div
>
<
div
class
=
"Spacer-15"
>
</
div
>
<
script
type
=
"text/javascript"
>
var genericErrorMessage = 'Error! An error has occured. Please try again and if the problem persists contact support.';
var gInventoryMobile; //grid object
var gGroupUpdate; //grid object
var gGroupUpdateDataSource = new Array; //group update DataSource
var wRadWindow;
var rRadWindowReturn;
var GroupUpdateSaveItems = false;
//sets the grid object ongridcreate
function getInventoryMobileGridObject(sender, e) {
gInventoryMobile = sender;
}
//sets the grid object ongridcreate
function getGroupUpdateGridObject(sender, e) {
gGroupUpdate = sender;
}
//utils//
function getGroupUpdateItem(id) {
for (var i = 0, len = gGroupUpdateDataSource.length; i <
len
; i++) {
if (gGroupUpdateDataSource[i].InventoryMobileDetailId === id)
return gGroupUpdateDataSource[i];
}
return null;
}
function setAlertFilterClass() {
currentFilter
=
getCurrentFilter
();
if (currentFilter == '0') {
$("#dvAlertFilter").addClass("IconAlert_Disabled");
}
else {
$("#dvAlertFilter").addClass("IconAlert_Enabled");
}
}
function displayWarningMessage(message) {
$("#dvStatusMessage").addClass("alert");
$("#dvStatusMessage").text(message);
$("#dvStatusMessage").slideDown(1000).delay(5000).slideUp(1000);
}
function displayFailureMessage(message) {
$("#dvStatusMessage").addClass("alert alert-failure");
$("#dvStatusMessage").text(message);
$("#dvStatusMessage").slideDown(1000).delay(5000).slideUp(1000);
}
function displaySuccessMessage(message) {
$("#dvStatusMessage").addClass("alert alert-success");
$("#dvStatusMessage").text(message);
$("#dvStatusMessage").slideDown(1000).delay(5000).slideUp(1000);
}
//utils//
//setup
$(document).ready(function () {
setDefaults();
//$("#btnExclude").click(function () {
// onExcludeClick();
//});
$("#btnClear").click(function () {
onClearClick();
});
});
function setDefaults() {
$("#ddlMobileApps").change(function () {
onMobileAppChange();
});
$("#ddlMobileAppSections").change(function () {
onMobileAppSectionChange();
});
$("#dvAlertFilter").click(function () {
onAlertFilterClick();
});
$("#btnAdd").click(function () {
onAddToGroupUpdate();
});
$("#dvStatusMessage").hide();
setAlertFilterClass();
populateMobileAppDropDown();
}
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(setDefaults);
//setup
//events
function gGroupUpdate_Command(sender, args) {
//get the grid item for which the command is fired
var
itemIndex
=
args
.get_commandArgument();
var
item
=
args
.get_tableView().get_dataItems()[itemIndex];
if (args.get_commandName() == "Remove") {
//get InventoryMobileDetailId
var
inventoryMobileDetailId
=
item
.get_cell("InventoryMobileDetailId").innerHTML;
var
mobileInventory
=
getGroupUpdateItem
(inventoryMobileDetailId);
if (mobileInventory != null)
gGroupUpdateDataSource.splice(mobileInventory, 1);
bindUpdateGrid();
}
//to stop postback
args.set_cancel(true);
}
function bindMobileAppDropDown(result) {
var mobileAppDropDown = $("#ddlMobileApps");
var listItems = [];
listItems.push("<option
value
=
'0'
>-Select Application-</
option
>");
for (var i = 0; i <
result.length
; i++) {
listItems.push("<option
value
=
'" + result[i].MobileAppId + "'
>" + result[i].Name + "</
option
>");
}
mobileAppDropDown.html(listItems.join(''));
}
function bindMobileAppSectionDropDown(result) {
var mobileAppDropDown = $("#ddlMobileAppSections");
var listItems = [];
listItems.push("<
option
value
=
'0'
>-Select Section-</
option
>");
for (var i = 0; i <
result.length
; i++) {
listItems.push("<option
value
=
'" + result[i].MobileAppSectionID + "'
>" + result[i].Name + "</
option
>");
}
mobileAppDropDown.html(listItems.join(''));
}
function bindMobileAppSubSectionDropDown(result) {
var mobileAppDropDown = $("#ddlMobileAppSubSections");
var listItems = [];
listItems.push("<
option
value
=
'0'
>-Select Sub Section-</
option
>");
for (var i = 0; i <
result.length
; i++) {
listItems.push("<option
value
=
'" + result[i].MobileAppSubSectionID + "'
>" + result[i].Name + "</
option
>");
}
mobileAppDropDown.html(listItems.join(''));
}
function onClearClick() {
gGroupUpdateDataSource = new Array();
bindUpdateGrid();
}
function confirmGroupUpdateKeepInGrid(val) {
var selectedMobileAppValue = $("#ddlMobileApps option:selected").val();
var selectedMobileAppSectionValue = $("#ddlMobileAppSections option:selected").val();
var selectedMobileAppSubSectionValue = $("#ddlMobileAppSubSections option:selected").val();
var MasterTable = gGroupUpdate.get_masterTableView();
var Rows = MasterTable.get_dataItems();
if (selectedMobileAppValue <= 0) {
displayWarningMessage("Warning! Please select a mobile application.");
return false;
}
if (selectedMobileAppSectionValue <= 0) {
displayWarningMessage("Warning! Please select a section.");
return false;
}
if (selectedMobileAppSubSectionValue <= 0) {
displayWarningMessage("Warning! Please select a sub section.");
return false;
}
if (Rows.length <= 0) {
displayWarningMessage("Warning! No Applications In Group Update.");
return false;
}
function aspButtonCallbackFn(arg) {
if (arg != null) {
if (val == 'Add') {
onIncludeClick(arg)
} else {
onRemoveClick(arg)
}
}
}
radconfirm("Would You Like To Keep Items in Group Update?", aspButtonCallbackFn, 220, 85, null, "Confirm");
}
function GetSectionVisiblityByInventoryID(InventoryID) {
var iGrid = gInventoryMobile;
var masterTable = iGrid.get_masterTableView();
var rows = masterTable.get_dataItems();
for (var i = 0; i <
rows.length
; i++) {
var
row
=
rows
[i];
var
IMinventoryId
=
masterTable
.getCellByColumnUniqueName(row, "InventoryId").innerHTML;
if (IMinventoryId == InventoryID) { return masterTable.getCellByColumnUniqueName(row, "SectionVisibilityGU").innerHTML; }
}
return "";
}
function onIncludeClick(KeepInGrid) {
var selectedMobileAppValue = $("#ddlMobileApps option:selected").val();
var selectedMobileAppText = $("#ddlMobileApps option:selected").text();
var selectedMobileAppSectionValue = $("#ddlMobileAppSections option:selected").val();
var selectedMobileAppSectionText = $("#ddlMobileAppSections option:selected").text();
var selectedMobileAppSubSectionValue = $("#ddlMobileAppSubSections option:selected").val();
var selectedMobileAppSUbSectionText = $("#ddlMobileAppSubSections option:selected").text();
var
updateCount
=
0
;
var
iGrid
=
gGroupUpdate
;
var
masterTable
=
iGrid
.get_masterTableView();
var
rows
=
masterTable
.get_dataItems();
for (var
i
=
0
; i < rows.length; i++) {
var
row
=
rows
[i];
var
inventoryId
=
masterTable
.getCellByColumnUniqueName(row, "InventoryId").innerHTML;
var
mobileAppId
=
masterTable
.getCellByColumnUniqueName(row, "MobileAppId").innerHTML;
if (mobileAppId.indexOf(selectedMobileAppValue) <= 0) {
data = {};
data.inventoryId
= inventoryId;
data.mobileAppId
=
selectedMobileAppValue
;
data.mobileAppSectionID
=
selectedMobileAppSectionValue
;
data.mobileAppSubSectionID
=
selectedMobileAppSubSectionValue
;
alert(data);
$.ajax({
type: "POST",
url: basePath + "/InsertInventoryMobileApp",
data: JSON.stringify(data),
contentType: 'application/json;
charset
=
utf
-8',
dataType: 'json',
async: false,
success: function (result) {
updateCount
= updateCount + 1; },
error: function (error) { displayFailureMessage(genericErrorMessage); }
});
}
}
gInventoryMobileBind();
setTimeout(function () {
if (KeepInGrid) {
for (var
i
=
0
; i < gGroupUpdateDataSource.length; i++) {
gGroupUpdateDataSource[i]
.SectionVisibility
=
GetSectionVisiblityByInventoryID
(gGroupUpdateDataSource[i].InventoryId);
}
} else {
gGroupUpdateDataSource
=
new
Array();
}
bindUpdateGrid();
},450);
displaySuccessMessage("Success! " + updateCount + " product(s) were updated to be included on the " + selectedMobileAppText + " application");
}
function onRemoveClick(KeepInGrid) {
var selectedMobileAppValue = $("#ddlMobileApps option:selected").val();
var selectedMobileAppText = $("#ddlMobileApps option:selected").text();
var selectedMobileAppSectionValue = $("#ddlMobileAppSections option:selected").val();
var selectedMobileAppSectionText = $("#ddlMobileAppSections option:selected").text();
var selectedMobileAppSubSectionValue = $("#ddlMobileAppSubSections option:selected").val();
var selectedMobileAppSUbSectionText = $("#ddlMobileAppSubSections option:selected").text();
var
updateCount
=
0
;
if (selectedMobileAppValue <= 0) {
displayWarningMessage("Warning! Please select a mobile application.");
return;
}
if (selectedMobileAppSectionValue <= 0) {
displayWarningMessage("Warning! Please select a section.");
return;
}
if (selectedMobileAppSubSectionValue <= 0) {
displayWarningMessage("Warning! Please select a sub section.");
return;
}
var
iGrid
=
gGroupUpdate
;
var
masterTable
=
iGrid
.get_masterTableView();
var
rows
=
masterTable
.get_dataItems();
for (var
i
=
0
; i < rows.length; i++) {
var
row
=
rows
[i];
var
inventoryId
=
masterTable
.getCellByColumnUniqueName(row, "InventoryId").innerHTML;
var
mobileAppId
=
masterTable
.getCellByColumnUniqueName(row, "MobileAppId").innerHTML;
if (mobileAppId.indexOf(selectedMobileAppValue) <= 0) {
data = {};
data.inventoryId
= inventoryId;
data.mobileAppId
=
selectedMobileAppValue
;
data.mobileAppSectionID
=
selectedMobileAppSectionValue
;
data.mobileAppSubSectionID
=
selectedMobileAppSubSectionValue
;
$.ajax({
type: "POST",
url: basePath + "/DeleteInventoryMobileApp",
data: JSON.stringify(data),
contentType: 'application/json;
charset
=
utf
-8',
dataType: 'json',
async: false,
success: function (result) {
updateCount
= updateCount + 1; },
error: function (error) { displayFailureMessage(genericErrorMessage); }
});
}
}
gInventoryMobileBind();
setTimeout(function () {
if (KeepInGrid) {
for (var
i
=
0
; i < gGroupUpdateDataSource.length; i++) {
gGroupUpdateDataSource[i]
.SectionVisibility
=
GetSectionVisiblityByInventoryID
(gGroupUpdateDataSource[i].InventoryId);
}
} else {
gGroupUpdateDataSource
=
new
Array();
}
bindUpdateGrid();
}, 450);
displaySuccessMessage("Success! " + updateCount + " product(s) were updated to be removed from the " + selectedMobileAppText + " application");
}
function onResweepClick() {
var selectedResweepValue = $("#ddlResweepTarget option:selected").val();
var
MasterTable
=
gGroupUpdate
.get_masterTableView();
var
Rows
=
MasterTable
.get_dataItems();
if (selectedResweepValue <= 0) {
displayWarningMessage("Warning! Please select a resweep target.");
return false;
}
if (Rows.length <= 0) {
displayWarningMessage("Warning! No Applications In Group Update.");
return false;
}
function aspButtonCallbackFn(arg) {
if (arg != null) {
resweepTargetAttachments(arg)
}
}
radconfirm("Would You Like To Keep Items in Group Update?", aspButtonCallbackFn, 220, 85, null, "Confirm");
}
function resweepTargetAttachments(KeepInGrid) {
var selectedResweepText = $("#ddlResweepTarget option:selected").val();
var
iGrid
=
gGroupUpdate
;
var
masterTable
=
iGrid
.get_masterTableView();
var
rows
=
masterTable
.get_dataItems();
var
updateCount
=
0
;
for (var
i
=
0
; i < rows.length; i++) {
var
row
=
rows
[i];
var
inventoryId
=
masterTable
.getCellByColumnUniqueName(row, "InventoryId").innerHTML;
var
mobileAppId
=
masterTable
.getCellByColumnUniqueName(row, "MobileAppId").innerHTML;
data = {};
data.inventoryId
= inventoryId;
data.resweepTargetType
=
selectedResweepText
;
$.ajax({
type: "POST",
url: basePath + "/ResweepInventoryMobileApp",
data: JSON.stringify(data),
contentType: 'application/json;
charset
=
utf
-8',
dataType: 'json',
async: false,
success: function (result) {
updateCount
= updateCount + 1; },
error: function (error) { displayFailureMessage(genericErrorMessage); }
});
}
if (!KeepInGrid) {
gGroupUpdateDataSource
=
new
Array();
bindUpdateGrid();
}
displaySuccessMessage("Success! " + updateCount + " product(s) were updated to be reswept");
}
function onAddToGroupUpdate() {
var
iGrid
=
gInventoryMobile
;
//var gGrid = $find("
var
masterTable
=
iGrid
.get_masterTableView();
var
selectedRows
=
masterTable
.get_selectedItems();
for (var
i
=
0
; i < selectedRows.length; i++) {
var
row
=
selectedRows
[i];
var
inventoryMobileDetailId
=
masterTable
.getCellByColumnUniqueName(row, "InventoryMobileDetailId").innerHTML;
var
bar_Code
=
masterTable
.getCellByColumnUniqueName(row, "Bar_Code").innerHTML;
var
title
=
masterTable
.getCellByColumnUniqueName(row, "Title").innerHTML;
var
mobileApp
=
masterTable
.getCellByColumnUniqueName(row, "MobileApp").innerHTML;
var
mobileAppId
=
masterTable
.getCellByColumnUniqueName(row, "MobileAppId").innerHTML;
var
inventoryId
=
masterTable
.getCellByColumnUniqueName(row, "InventoryId").innerHTML;
var
section_visibility
=
masterTable
.getCellByColumnUniqueName(row, "SectionVisibilityGU").innerHTML;
var
inventory
=
new
inventoryMobileModel(inventoryMobileDetailId, bar_Code, title, mobileApp, mobileAppId, inventoryId,section_visibility);
//add it to the datasource
if (getGroupUpdateItem(inventory.InventoryMobileDetailId) == null)
gGroupUpdateDataSource[gGroupUpdateDataSource.length] = inventory;
masterTable.deselectItem(row.get_element());
}
bindUpdateGrid();
}
function onAlertFilterClick() {
var
currentFilter
=
getCurrentFilter
();
var
tableView
=
gInventoryMobile
.get_masterTableView();
if (currentFilter == '0') {
tableView.filter("AlertFilter", 0, "EqualTo");
}
else {
tableView.filter("AlertFilter", 0, "NoFilter");
}
}
function bindUpdateGrid() {
var
grid
=
gGroupUpdate
;
var
masterTable
=
grid
.get_masterTableView();
masterTable.set_dataSource(gGroupUpdateDataSource);
$("#dvGroupUpdate").find("a").addClass("buttonAction");
masterTable.dataBind();
}
function gInventoryMobileBind() {
var
masterTable
=
gInventoryMobile
.get_masterTableView();
masterTable.rebind();
}
//events
//Ajax//
function populateMobileAppDropDown() {
$.ajax({
type: "POST",
url: basePath + "/GetMobileApplications",
contentType: 'application/json;
charset
=
utf
-8',
dataType: 'json',
success: function (result) { bindMobileAppDropDown(result.d); bindMobileAppSectionDropDown([]); bindMobileAppSubSectionDropDown([]); },
error: function (error) { failureCallBack(error); }
});
}
function onMobileAppChange() {
data = {};
data.MobileAppId = $("#ddlMobileApps option:selected").val();
$.ajax({
type: "POST",
url: basePath + "/GetMobileApplicationsSections",
contentType: 'application/json;
charset
=
utf
-8',
data: JSON.stringify(data),
dataType: 'json',
success: function (result) { bindMobileAppSectionDropDown(result.d); bindMobileAppSubSectionDropDown([]); },
error: function (error) { failureCallBack(error); }
});
}
function onMobileAppSectionChange() {
data = {};
data.MobileAppSectionID = $("#ddlMobileAppSections option:selected").val();
$.ajax({
type: "POST",
url: basePath + "/GetMobileApplicationsSubSections",
contentType: 'application/json;
charset
=
utf
-8',
data: JSON.stringify(data),
dataType: 'json',
success: function (result) {bindMobileAppSubSectionDropDown(result.d);
},
error: function (error) { failureCallBack(error); }
});
}
function removeMobileApp(inventoryId, mobileAppId) {
}
function addMobileApp(inventoryId, mobileAppId) {
}
function addMobileAppSuccess(id) {
}
function failureCallBack(error) {
alert(error.responseText);
};
//Ajax//
function inventoryMobileModel(inventoryMobileDetailId, bar_Code, title, mobileApp, mobileAppId, inventoryId, section_visibility) {
this.Bar_Code
=
bar_Code
;
this.Title
=
title
;
this.MobileApp
=
mobileApp
;
this.MobileAppId
=
mobileAppId
;
this.InventoryMobileDetailId
=
inventoryMobileDetailId
;
this.InventoryId
=
inventoryId
;
this.SectionVisibility
=
section_visibility
;
}
function mngRequestStarted(ajaxManager, eventArgs) {
if (eventArgs.get_eventTarget().indexOf("btnExport") != -1)
eventArgs.set_enableAjax(false);
}
</script>
</
asp:Content
>
VB:
Protected
Sub
gInventoryMobile_NeedDataSource(sender
As
Object
, e
As
Telerik.Web.UI.GridNeedDataSourceEventArgs)
Handles
gInventoryMobile.NeedDataSource
Dim
inventoryMobileCollection =
New
List(Of InventoryMobileDTO)
inventoryMobileCollection = GetGridData()
gInventoryMobile.DataSource = inventoryMobileCollection
End
Sub
Protected
Function
GetGridData()
As
List(Of InventoryMobileDTO)
Dim
inventoryMobileCollection =
New
List(Of InventoryMobileDTO)
Dim
inventoryMobileProcess
As
New
InventoryMobileProcess(
New
JNL.SuperFulfillment.DataBase)
inventoryMobileCollection = inventoryMobileProcess.GetInventoryMobile(
False
)
Dim
startRowIndex
As
Integer
=
If
((ShouldApplySortFilterOrGroup()), 0, gInventoryMobile.CurrentPageIndex * gInventoryMobile.PageSize)
Dim
maximumRows
As
Integer
=
If
((ShouldApplySortFilterOrGroup()), inventoryMobileCollection.Count, gInventoryMobile.PageSize)
If
(gInventoryMobile.VirtualItemCount > inventoryMobileCollection.Count)
Then
gInventoryMobile.VirtualItemCount = inventoryMobileCollection.Count
Return
inventoryMobileCollection.Skip(startRowIndex).Take(gInventoryMobile.PageSize).ToList
End
Function
Protected
Sub
tSectionVisibilityFilter_OnTextChanged(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Dim
tFilter
As
TextBox = TryCast(sender, TextBox)
For
Each
gColumn
As
GridColumn
In
gInventoryMobile.MasterTableView.Columns
If
gColumn.UniqueName.Equals(
"SectionVisibility"
)
Then
If
IsNullOrEmpty(tFilter.Text)
Then
gColumn.CurrentFilterFunction = GridKnownFunction.NoFilter
gColumn.CurrentFilterValue =
String
.Empty
Else
gColumn.CurrentFilterFunction = GridKnownFunction.Contains
gColumn.CurrentFilterValue = tFilter.Text
End
If
ViewState(tFilter.ID) = tFilter.Text
TryCast(tFilter.NamingContainer, GridFilteringItem).FireCommandEvent(
"Filter"
,
New
Pair(gColumn.CurrentFilterFunction.ToString, gColumn.CurrentFilterValue))
End
If
Next
End
Sub
Protected
Sub
FilterCombo_SelectedIndexChanged(
ByVal
o
As
Object
,
ByVal
e
As
RadComboBoxSelectedIndexChangedEventArgs)
Dim
rFilter
As
RadComboBox = TryCast(o, RadComboBox)
Dim
sCheckedItems
As
New
List(Of
String
)
For
Each
gColumn
As
GridColumn
In
gInventoryMobile.MasterTableView.Columns
If
gColumn.UniqueName.Equals(
"AttachmentTypes"
)
Then
If
IsNullOrEmpty(rFilter.SelectedValue)
Then
gColumn.CurrentFilterFunction = GridKnownFunction.NoFilter
gColumn.CurrentFilterValue =
String
.Empty
Else
Dim
CheckedCollection
As
List(Of RadComboBoxItem) = TryCast(rFilter.CheckedItems, List(Of RadComboBoxItem))
For
Each
rCBI
As
RadComboBoxItem
In
rFilter.CheckedItems
sCheckedItems.Add(rCBI.Value.ToLower)
Next
If
sCheckedItems.Count = 0
Then
gColumn.CurrentFilterFunction = GridKnownFunction.NoFilter
gColumn.CurrentFilterValue =
String
.Empty
Else
gColumn.CurrentFilterFunction = GridKnownFunction.Custom
gColumn.CurrentFilterValue =
"(([AttachmentTypes] LIKE '%"
&
String
.Join(
"%') OR ([AttachmentTypes] LIKE '%"
, sCheckedItems.ToArray) &
"%'))"
End
If
End
If
ViewState(rFilter.ID) =
String
.Join(
","
, sCheckedItems.ToArray)
TryCast(rFilter.NamingContainer, GridFilteringItem).FireCommandEvent(
"Filter"
,
New
Pair(gColumn.CurrentFilterFunction.ToString, gColumn.CurrentFilterValue))
End
If
Next
End
Sub
Protected
Sub
gInventoryMobile_ItemDataBound(sender
As
Object
, e
As
GridItemEventArgs)
Handles
gInventoryMobile.ItemCreated
If
(
TypeOf
e.Item
Is
GridDataItem)
Then
Dim
item
As
GridDataItem =
CType
(e.Item, GridDataItem)
Dim
inventoryMobileId
As
Integer
=
CType
(item.GetDataKeyValue(
"InventoryMobileDetailId"
),
Integer
)
If
inventoryMobileId <= 0
Then
item.SelectableMode = GridItemSelectableMode.None
Else
item.SelectableMode = GridItemSelectableMode.ServerAndClientSide
End
If
'ElseIf (TypeOf e.Item Is GridFilteringItem) Then
' TryCast(e.Item, GridFilteringItem)("AttachmentTypes").Text = " "
End
If
End
Sub
Protected
Sub
cAttachmentFilter_PreRender(sender
As
Object
, e
As
EventArgs)
Dim
rFilter
As
RadComboBox = TryCast(sender, RadComboBox)
If
Not
IsNullOrEmpty(ViewState(rFilter.ID))
Then
Dim
CheckedCollection
As
List(Of
String
) = Split(ViewState(rFilter.ID).ToString,
","
).ToList
For
Each
rCBI
As
RadComboBoxItem
In
rFilter.Items
If
CheckedCollection.Contains(rCBI.Value.ToLower)
Then
rCBI.Checked =
True
Next
End
If
End
Sub
Protected
Sub
tSectionVisibilityFilter_PreRender(sender
As
Object
, e
As
EventArgs)
Dim
tFilter
As
TextBox = TryCast(sender, TextBox)
If
Not
IsNullOrEmpty(ViewState(tFilter.ID))
Then
tFilter.Text = ViewState(tFilter.ID).ToString
End
If
End
Sub
0
Hello Brian,
From the provided code it seems that the grid is configured to use custom paging. Following the scenario I have assembled a sample website with a grid that uses custom paging but in my case the CurrentPageIndex and PageSize were changed on the server and the paging did work as expected. Could you please examine the attached website and tell us what differs in your case?
Additionally please try-out the following.
Regards,
Angel Petrov
Telerik
From the provided code it seems that the grid is configured to use custom paging. Following the scenario I have assembled a sample website with a grid that uses custom paging but in my case the CurrentPageIndex and PageSize were changed on the server and the paging did work as expected. Could you please examine the attached website and tell us what differs in your case?
Additionally please try-out the following.
- Disable the AJAX and test whether an exception is thrown.
- Verify that a client-side error is not present on the page prior the paging.
Finally, please elaborate on the exact controls version that the application targets. Maybe this is an issue in the older version of the controls but is already fixed.
Regards,
Angel Petrov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0

Brian
Top achievements
Rank 1
answered on 05 Jun 2014, 10:20 PM
Hi Angel,
I have tried both CustomPaging and standard Paging and neither work correctly with the goto specific page or page size functions. The numberic page controls (next,previous, first,last and page numbers) work fine. I have tried disabling AJAX and this did not cause throw an exception and there are not any client side errors. In fact, the page posts the exact same way for the functioning and not functioning portions of the paging element. Your example unfortunately did not help since my Grid is much more robust than what you provided. The Telerik version I am using is: 2012.3.1205.40.
Any help would be appreciated.
Thanks!
Brian
I have tried both CustomPaging and standard Paging and neither work correctly with the goto specific page or page size functions. The numberic page controls (next,previous, first,last and page numbers) work fine. I have tried disabling AJAX and this did not cause throw an exception and there are not any client side errors. In fact, the page posts the exact same way for the functioning and not functioning portions of the paging element. Your example unfortunately did not help since my Grid is much more robust than what you provided. The Telerik version I am using is: 2012.3.1205.40.
Any help would be appreciated.
Thanks!
Brian
0
Hi Brian,
Probably the described behavior is a bug in the older version of the controls and is now fixed. Please test the application using the latest version and let us know of the results.
If the issue persists I would like to ask you to modify the sample provided in my previous post in such a manner so that it can be observed. That would be of great help as we will be able to debug the code and find the root cause of the problem.
Regards,
Angel Petrov
Telerik
Probably the described behavior is a bug in the older version of the controls and is now fixed. Please test the application using the latest version and let us know of the results.
If the issue persists I would like to ask you to modify the sample provided in my previous post in such a manner so that it can be observed. That would be of great help as we will be able to debug the code and find the root cause of the problem.
Regards,
Angel Petrov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.