This is a migrated thread and some comments may be shown as answers.
Clearing all rows in the MVC Telerik Grid
3 Answers 105 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Anthony
Top achievements
Rank 1
Anthony asked on 21 Apr 2012, 07:10 AM
Hi,

I have a telerik grid in my MVC application. I add rows to it using the following line

var grid = $("#ParentSpecialities").data("tGrid");
var griddata = grid.data;

griddata.push({ SpecialityID: data.Specialities[i].SpecialityID, ServiceName: data.Specialities[i].ServiceName, IsAssociatedSpeciality: data.Specialities[i].IsAssociatedSpeciality, IsCommonDiagnosis: data.Specialities[i].IsCommonDiagnosis });

grid.dataBind(griddata);


This works perfectly. However, I wish to first clear the grid (remove all the rows) and then use griddata.push(...)

Is that possible? I need to do that to avoid duplicate entries. Please advise

Thanks,
Anthony

3 Answers, 1 is accepted

Sort by
0
Pechka
Top achievements
Rank 1
answered on 21 Apr 2012, 07:20 AM
Yo mate

Then use:
$(Grid).data().tGrid.total=0 $(Grid).data().tGrid.dataBind([]) 

Also you can use the addRow method instead of custom logic.
0
Anthony
Top achievements
Rank 1
answered on 21 Apr 2012, 09:51 AM
Thank you very much!
That worked :)
0
RahulD
Top achievements
Rank 1
answered on 18 Oct 2012, 04:27 AM
but yet there is some problem with grid binding.
i am not able to push the data in

var griddata = grid.data;
griddata.push
({});               --this statement is not working

the griddata when i bind it does not binded to the grid.

Thanks and waiting for an answer.
Tags
Grid
Asked by
Anthony
Top achievements
Rank 1
Answers by
Pechka
Top achievements
Rank 1
Anthony
Top achievements
Rank 1
RahulD
Top achievements
Rank 1
Share this question
or