This is a migrated thread and some comments may be shown as answers.

EditItemTemplate for MasterTableView

7 Answers 154 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dmitry
Top achievements
Rank 1
Dmitry asked on 21 Dec 2011, 12:07 PM
Hello,
I'm going to implement a grid's CardView feature and create a grid from server side. This is what I do:
MasterTableView.ItemTemplate = new CardViewItemTemplate(owner.ZSheet, owner.CardLayout);
MasterTableView.EditItemTemplate = new CardViewEditItemTemplate(owner.ZSheet, owner.CardLayout);

Each template is going to contain a custom control which is actually HtmlTable descendant which contains Label controls in ItemTemplate and editor controls like TextBox and so on in EditItemTemplate. Everything is clear with ItemTemplate but in EditItemTemplate I need to implement IBindableTemplate. Any ideas of how it should be done?
I would appreciate any sample of how CardView templates are created from codebehind.

7 Answers, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 1
answered on 22 Dec 2011, 05:54 PM
Dmitry:

Take a look at this older forum thread. I believe that it will provide some insights on creating the IBindableTemplate for your CardView.
 InstantiateIn & ExtractValues in IBindableTemplate

Cheers!
0
Dmitry
Top achievements
Rank 1
answered on 10 Jan 2012, 03:03 PM
Hello,
Thank you for reply, this makes a sense to me. But I have a problem. This is what I do:
1. I have 2 grids inherited from RadGrid, first represents a regular grid, and second is a grid with card view. Each single moment only one type of grid is created, this depends on some conditions.
2. Grid is created from Page_Init and properly initialized and bound to data. I emphisize this to avoid posts like "Did you properly bind grid to data as described in this or that post?" Everything works fine on regular grid - inserts, updates and deletes.
3. This is how I initialize card view: 

MasterTableView.EditMode = GridEditMode.InPlace;
MasterTableView.ItemTemplate = new CardViewItemTemplate(owner.ZSheet, owner.CurrentTable, owner.CardLayout, owner.CorrectionRows);
MasterTableView.EditItemTemplate = new CardViewEditItemTemplate(owner.ZSheet, owner.CurrentTable, owner.CardLayout, owner.CorrectionRows);  
4. Edit template contains custom controls which all implement IScriptingControl and inherit CompositeControl
5. On card view template I have custom buttons which fire edit/update/cancel commands from client side, like fireCommand("Edit", rowIndex)
6. In both cases I create a columns collection, all columns are of TemplateColumn type, except an "id" column which is a GridBoundColumn with Display property set to false.

Now about the problem itself. Edit command properly sets card to edit mode, all edit controls renders properly. But when I fire Update command and handle ItemCommand event, GridEditableItem.ExtractValues returns collection containing the only empty item. I can see that in a regular grid's edit template ExtractValues method is called before ItemCommand event, but in card view edit template it was not, and that could be a reason. 
This is how I handle ItemCommand event with Update command:
case UpdateCommandName:
case UpdateEditedCommandName:
     GridEditableItem editItem = (GridEditableItem)e.Item;
     Dictionary<stringobject> editValues = new Dictionary<stringobject>();
     editItem.ExtractValues(editValues);
So editValues collection contains only a single empty item with key "id". As I said above, it was a single column which was not a TemplateColumn. 
What should I do to run card view edit template's ExtractValues method?
Thank you
0
Dmitry
Top achievements
Rank 1
answered on 11 Jan 2012, 01:15 PM
Anyone?
0
Mira
Telerik team
answered on 13 Jan 2012, 09:59 AM
Hello Dmitry,

I suggest you make sure that you follow this help topic when inheriting the grid.

Please note that we do not support issues with inherited versions of RadGrid and the purpose of the topic is to provide basic instructions how to inherit your custom grid control from RadGrid.

I hope this helps.

Kind regards,
Mira
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Dmitry
Top achievements
Rank 1
answered on 13 Jan 2012, 03:14 PM
Hello,
Everything I did with inherited grid was adding some properties and methods. I didn't override or overload anything. I didn't modify or inherit MasterTableView or ANY part of RadGrid. My grid contains only MasterTableView and no detail views.  Everything had worked fine until the moment I tried to implement card view. As I told you before, I use TemplateColumns which work perfectly. But when I tried to use MasterTableView.EditItemTemplate, it would never work.
0
Dmitry
Top achievements
Rank 1
answered on 16 Jan 2012, 11:40 AM
I created a support ticket #501757 and uploaded a sample project there. No inheritance there, I used only RadGrid but this is not working anyway.
Please look at it.
0
Mira
Telerik team
answered on 17 Jan 2012, 10:49 AM
Hello Dmitry,

I have answered your support ticket concerning the same issue. In order to avoid duplicate posts, I suggest that we continue the communication in it.

Kind regards,
Mira
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Dmitry
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Dmitry
Top achievements
Rank 1
Mira
Telerik team
Share this question
or