Can some expert propose a way to use Telerik RadControls Ajax Grids and MongoDb C# Official driver to manage a simple Grid table Create/Update/Delete methods. The object is managing a simple Table data from a web control.
- What are the best object to use : BsonObjects, List, DataTables
- Best ways cl开发者_如何转开发ient or server side
Thanks.
- Use FindAs to load some collection from database(probably you will also use skip, limit, and SetSor tOrder).
- I am not familiar with telerik-grid at all but it seems to me that as usual grid, telerik grid has some property like DataSource. So you can bind data using DataSource property.
- For the update/delete/insert methods i suppose telerik grid has some kind of events(like on item insert, delete). And you can easy create methods thats will be update/delete/insert in mongo.
In abstract process will looks like:
var items = mongoCollection.FindAs<Type>(Query.EQ("someProperty", "someValue"))
.SetSortOrder("orderField").SetLimit(100).Skip(10);
telerikGrid.DataSource = items;
telerikGrid.DataBind();
....
telerikGrid_OnItemDelete(object sender, SomeEventArgs e)
{
var id = e. //get parameter from args
..
mongoCollection.Remove(Query.EQ("_id", id));
}
Also i suggest you ask question about telerik grid( How to bind list of data to telerik grid?), or take a look into telerik documentation (i suppose that telerik has perfect documentation). Or even ask telerik community.
Hope my 'abstract' answer somehow help you.
精彩评论