Dear Telerik,
We are experiencing a strange thing with the RadGrid. We have set up a RadGrid clientside, all clientside. Paging, Adding and Deleting are done clientside.
What we come across is that every second time we Delete a row(by calling the deleteCustomer function) the masterTable.deleteSelectedItems(); is not executed. But the console.log just above it is executed so it makes it too that function each time you want to delete an item.
The basic idea of deleting these items is that when a row is selected, an javascript array is filled with IDs and when the deleteCustomer function is executed, it fires an ajax call to the webservice to do database updates. And after waiting for the result to come back, it deletes the row from the grid.
Is there a bug in the RadGrid that makes it unavailable for a small time or are we not implementing this correctly?
I have put the RadGrid and Jquery code beneath.
By the way, we also used masterTable.rebind function instead of the deleteSelectedItems but that has the same effect.
Thank you for your time.
Vincent
We are experiencing a strange thing with the RadGrid. We have set up a RadGrid clientside, all clientside. Paging, Adding and Deleting are done clientside.
What we come across is that every second time we Delete a row(by calling the deleteCustomer function) the masterTable.deleteSelectedItems(); is not executed. But the console.log just above it is executed so it makes it too that function each time you want to delete an item.
The basic idea of deleting these items is that when a row is selected, an javascript array is filled with IDs and when the deleteCustomer function is executed, it fires an ajax call to the webservice to do database updates. And after waiting for the result to come back, it deletes the row from the grid.
Is there a bug in the RadGrid that makes it unavailable for a small time or are we not implementing this correctly?
I have put the RadGrid and Jquery code beneath.
By the way, we also used masterTable.rebind function instead of the deleteSelectedItems but that has the same effect.
Thank you for your time.
Vincent
<
telerik:RadGrid
ID
=
"AudienceRecipientsGrid"
runat
=
"server"
Width
=
"695"
AllowPaging
=
"True"
PageSize
=
"15"
AutoGenerateColumns
=
"false"
AllowMultiRowSelection
=
"true"
>
<
HeaderContextMenu
CssClass
=
"GridContextMenu GridContextMenu_Default"
></
HeaderContextMenu
>
<
MasterTableView
TableLayout
=
"Fixed"
DataKeyNames
=
"CustomerID"
ClientDataKeyNames
=
"CustomerID"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"CustomerID"
DataType
=
"System.Int32"
FilterControlAltText
=
"Filter CustomerID column"
HeaderText
=
"CustomerID"
SortExpression
=
"CustomerID"
UniqueName
=
"CustomerID"
Visible
=
"False"
ReadOnly
=
"True"
></
telerik:GridBoundColumn
>
<
telerik:GridClientSelectColumn
UniqueName
=
"ClientSelectColumn"
HeaderStyle-Width
=
"6%"
ItemStyle-Width
=
"6%"
>
<
HeaderStyle
Width
=
"6%"
></
HeaderStyle
>
<
ItemStyle
Width
=
"6%"
></
ItemStyle
>
</
telerik:GridClientSelectColumn
>
<
telerik:GridBoundColumn
DataField
=
"Name"
FilterControlAltText
=
"Filter Name column"
HeaderText
=
"Voornaam"
SortExpression
=
"Name"
UniqueName
=
"Name"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"SurName"
FilterControlAltText
=
"Filter SurName column"
HeaderText
=
"Achternaam"
SortExpression
=
"SurName"
UniqueName
=
"SurName"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Email"
FilterControlAltText
=
"Filter Email column"
HeaderText
=
"E-mail"
SortExpression
=
"Email"
UniqueName
=
"Email"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"joindate"
DataType
=
"System.DateTime"
FilterControlAltText
=
"Filter joindate column"
HeaderText
=
"Inschrijfdatum"
DataFormatString
=
"{0:dd/MM/yyyy HH:mm:ss}"
UniqueName
=
"joindate"
ReadOnly
=
"true"
></
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"true"
EnableDragToSelectRows
=
"false"
/>
<
Scrolling
AllowScroll
=
"False"
EnableVirtualScrollPaging
=
"True"
UseStaticHeaders
=
"True"
></
Scrolling
>
<
DataBinding
Location
=
"~/ems/EMSWS.asmx"
StartRowIndexParameterName
=
"startRowIndex"
MaximumRowsParameterName
=
"maxRows"
></
DataBinding
>
<
ClientEvents
OnRowSelected
=
"RowSelected"
OnRowDeselected
=
"RowDeselected"
OnRowCreated
=
"RowCreated"
OnRowDataBound
=
"RowDataBound"
/>
</
ClientSettings
>
<
PagerStyle
Mode
=
"NumericPages"
/>
<
FilterMenu
EnableImageSprites
=
"False"
></
FilterMenu
>
</
telerik:RadGrid
>
<
span
onclick
=
"deleteCustomers()"
class
=
"cms_hyperlink"
>Ontvangers verwijderen</
span
>
All grid logic is done here:
//Grid logic
var
selected = {};
function
RowSelected(sender, args) {
var
customerID = args.getDataKeyValue(
"CustomerID"
);
if
(!selected[customerID]) {
selected[customerID] = customerID;
}
}
function
RowDataBound(sender, args) {
//Every time a new page is loaded, all rows are unselected....
var
customerID = args.get_dataItem()[
"CustomerID"
];
if
(selected[customerID]) {
args.get_item().set_selected(
true
);
}
else
{
args.get_item().set_selected(
false
);
}
}
function
RowDeselected(sender, args) {
var
customerID = args.getDataKeyValue(
"CustomerID"
);
if
(selected[customerID]) {
selected[customerID] =
null
;
}
}
function
RowCreated(sender, args) {
var
customerID = args.getDataKeyValue(
"CustomerID"
);
if
(selected[customerID]) {
args.get_gridDataItem().set_selected(
true
);
}
}
//Deleting customers
function
deleteCustomers() {
WSdeleteCustomers();
}
function
WSdeleteCustomers() {
var
dfd =
new
jQuery.Deferred();
$.ajax({
type:
'POST'
,
url:
"/ems/emsws.asmx/RemoveEmailFromAudience"
,
dataType:
"json"
,
contentType:
"application/json; charset=utf-8"
,
data:
"{ 'strCustomerIDs': '"
+ GetSelectedCustomers() +
"', 'iAudienceID': '"
+ getParameterByName('id
') + "'
}",
cache:
false
,
success:
function
(data) {
dfd.resolve();
}
}).done(
function
() {
dfd.promise();
}).pipe(
function
() {
reloadGridAfterDelete();
});
}
function
GetSelectedCustomers() {
var
allids =
''
;
var
grid = $find(
"<%=AudienceRecipientsGrid.ClientID %>"
);
var
MasterTable = grid.get_masterTableView();
var
selectedRows = MasterTable.get_selectedItems();
for
(
var
i
in
selected) {
allids = allids + i +
','
;
}
return
allids;
}
function
reloadGridAfterDelete() {
//console.log("reload grid");
var
masterTable = window.$find(
"<%= AudienceRecipientsGrid.ClientID %>"
).get_masterTableView();
//masterTable.rebind();
console.log(
"deleteSelectedItems()"
);
masterTable.deleteSelectedItems();
}