i am having problem when adding row programatically,, i have got a simple row..with only a fild and i am using paging..
the code for adding 6 consecutives rows..
$('#grid_Software').igGridUpdating('addRow', { 'IDSoftware': 1 }); $('#grid_Software').igGridUpdating('addRow', { 'IDSoftware': 3 }); $('#grid_Software').igGridUpdating('addRow', { 'IDSoftware': 1 }); $('#grid_Software').igGridUpdating('addRow', { 'IDSoftware': 3}); $('#grid_Software').igGridUpdating('addRow', { 'IDSoftware': 1 }); $('#grid_Software').igGridUpdating('addRow', { 'IDSoftware': 3 }); $('#grid_Software').igGrid("commit");
the code for the grid..
@( Html.Infragistics().Grid().ID("grid_Software").DefaultColumnWidth("100px")
.PrimaryKey("IDSoftware") .Columns(column =>
column.For(x => x.IDSoftware ); }) .Features(features => { features.Paging().PageSize(5).PrevPageLabelText("Previous").NextPageLabelText("NEXT").RecordCountKey("TotalCount"); features.Sorting().Mode(SortingMode.Single); features.Selection().MultipleSelection(false).Mode(SelectionMode.Row); features.Filtering().Mode(FilterMode.Simple); features.Updating() //.EnableDataDirtyException(true) .EnableAddRow(false) .EnableDeleteRow(true) .EditMode(GridEditMode.None); }) .UpdateUrl(Url.Action("SaveSoftwareToProcesso")) .Height("300px") .Render())
has you can see i am using pager, show 5 records per page..
the problem is that after adding 6 rows the pager says 2 pages, it also says 1-5 of 6 records..everything is ok..
now in the records in the 1 page it displays all of the 6 records, the if i select the 2nd page everything is ok, the last record show, and them i move to the first page and the page shows 5 records..
i have tried to use databind but if i do that the i loose all the transactions..
how can i resolve this..
thanks
so, i was thinking that the problem was mine, so i use the demo on editing api and events page, and just add the paging code..
if i add 2 more rows...the same thing happens, it shows me 11 rows on the first page , but the pager information on the footer
is correct..
if a press page 1 or 2 , the data is reloaded and it appears correctly now.
and here i was thinking that i solved the problem...no it stil maintain...i will create a project and upload here..
Is this supossed to happen with the grid when adding rows programaticaly?
here is link to dowload a test project in mvc 4.0
http://we.tl/6esCyIN9P4
can anyone help me...
My solution
so after a lot of digging and trial and error, i manage to found a solution, it's not the best,but it is working.
so during the test i have realize that after adding 6 consecutive rows, if i change the current page index to the number two then back to number 1, it refresh the grid and now the rows appear correctyle, 5 in page 1, and one on page 2.
so i create a function that gives me the number os the current page , and the page size value...
if greater then i change the page index to 2 then back to 1.
function add_Row()
{
$('#grid1').igGridUpdating('addRow', { 'ID': 1 }); $("#grid1").igGrid("commit");
//get the page size value var size = $("#grid1").igGridPaging("pageSize");
//get the number of records on the current page. var rows = $("#grid1").igGrid("allRows"); var size2 = rows.length; alert(size2);
if (size2 > size) { $("#grid1").igGridPaging("pageIndex", 2); $("#grid1").igGridPaging("pageIndex", 0); }
}
if there is a better solution please tell me..
thanks again
Hello Hugo,
The issue you are seeing is caused by Paging and Updating not working together in the most obvious way possible and some internal limitations which we are looking to resolve in the future. Generally speaking the grid should behave as you are expecting, that is, rows added above the page size threshold should instead force the grid to change the page index to the page that would contain the new row so the action is immediately observable by the end-user. I've logged this in our internal system with ID 167407. The case opened for this forum post will be linked to the internal item and you'll be notified about updates through the case directly.
To work around this you can either proceed with your own implementation or data bind the grid after calling saveChanges so the remote data source is updated with the newly added records prior to the data binding call.
Please, let me know if you have any other questions and/or concerns!
Best regards,
Stamen Stoychev
ok, thanks for the help, once again..for now i will go with my implmentation, as soon as i receive some updates about this i will try and give you guys my feedback.
thank once again, for the help.
Hugo
Thank you for letting us know about this.
Also if there is something else that we could help you with, contact us again.
hi, there was a recent release, and in that release this problem should be resolved,,,i will try and tell how it worked.
Hello Hugo,Please feel free to contact us if you have any additional questions regarding this matter.