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

Custom GridEditFormInsertItem while triggering the MyGrid.MasterTableView.IsItemInserted = True

2 Answers 222 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sophie
Top achievements
Rank 2
Sophie asked on 26 Feb 2013, 09:25 PM
Hello!
I searched a while for this issue and can't seem to find. I have a multipage radtabstrip. When i click a radbutton in the first tab, i want the thrid one to open, load data, then trigger the insert command in the grid inside the 3rd tab.
Everything works from the moments i arrive in the load of my 3rd tab. My EventArguments still have what i sent from the first tab.

For the sake of showing my problem, here is how i do it from the javascript file:
//Client side function called by my button in the first tab:
triggerMyThridTab: function() {
    this._needToAdd = true;
    this._tabs.get_tabs().getTab(2).set_selected(true);
}
//.... calling the selected function
onTabSelected: function(sender, args){
    if(this._needToAdd){
      sender._userControl._needToAdd = true;
      sender._userControl._myThridTab.raise_load();
    }
}
//In my thirdTab usercontrol load function....
raise_load: function(){
    if(this._needToAdd){
      var myAction = "addNewEntry";
      eval("var exec = function() { $find(window.idAjaxManager).ajaxRequestWithTarget('" + this._triggerUniqueID + "', '\\{ \\'Action\\':\\'" + myAction + "\\'}' ); }");
      ExecRequeteAjax(this, exec, 5, null);//This calls the postback
    }
}

Then, i have this in my third tab load function :
'This is the userControl contained in the third tab
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  If ValidateEventArguments() Then
    'I must open the grid in insert mode
    MyGrid.MasterTableView.IsItemInserted = True
    MyGrid.Rebind()
  End If
End Sub

In my Third tab, i have a grid with a custom userControl for the edit form:
<telerik:RadGrid ID="MyGrid" runat="server" >
   <EditFormSettings EditFormType="WebUserControl" UserControlName="~/UserControls/MyAddItemCustomUC.ascx" />
   <Columns>....</Columns>
</telerik:RadGrid>


My Problem is, i need to pass some viewstate properties to the userControl. Normally i do this in the grid itemCreated() function when the item is type of GridEditFormInsertItem.
Protected Sub MyGrid_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles MyGrid.ItemCreated
  If TypeOf e.item Is GridEditFormInsertItem Then
    Dim control As MyCustomEditUC = DirectCast(e.Item.FindControl(GridEditFormInsertItem.EditFormUserControlID), MyCustomEditUC)
    control.SomePropreties = PropretiesInViewState
  End If
End Sub

When i load the customUC, my properties is set, and i can use it. But, if i write IsItemInserted somewhere.... that variable is never set and my website crashes. I can't put the variable in the viewstate anywhere else, security issues, and thats how the website was made before i added this feature.

I hope my explanations were clear and someone might be able to answer me cause i really don't know what to do...

2 Answers, 1 is accepted

Sort by
0
Sophie
Top achievements
Rank 2
answered on 27 Feb 2013, 02:53 PM
Edit:
Hello, I'm still on this issue. I tried to follow the examples from http://stackoverflow.com/questions/4379448/how-do-i-set-telerik-radgrid-to-edit-mode-by-default-asp-net and http://www.telerik.com/community/forums/aspnet/grid/confused-about-firecommandevent-from-button-outside-radgrid.aspx.
I made a separate test with a simple grid and adding :
Private Sub MyRadGrid_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyRadGrid.PreRender
  MyRadGrid.MasterTableView.IsItemInserted = True
  MyRadGrid.Rebind()
End Sub

and it seems to work. I'll do more test when using a custom userControl for the insert command... I'll update if i find something.
0
Sophie
Top achievements
Rank 2
answered on 27 Feb 2013, 04:03 PM
Hey telerik team, i finally found my problem. 
When i was getting some value in my custom user control, i was doing it in the page load. I moved it to the page prerender and works like a charm. :D
Tags
Grid
Asked by
Sophie
Top achievements
Rank 2
Answers by
Sophie
Top achievements
Rank 2
Share this question
or