Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
168 views
Hi,

We have decided to use a custom way of creating and showing recurrence appointments.
Now i would like to know how i can show the recurrence image in the appointment.
Is there a way to get the image from the scheduler so i can add it to the appointment template in the timeslotcreated event.

We are using the following code to show the appointment:

function TimeSlotCreated(sender, e) {  
 
 
      var app = e.get_appointment();  
      var element = e.get_appointment().get_element();  
 
      var attributeCollection = app.get_attributes();  
      var StateIconName = attributeCollection.getAttribute("StateIconName");  
      var SubStateIconName = attributeCollection.getAttribute("SubStateIconName");  
      var RsCategory = RgbStringToRadStyleString(attributeCollection.getAttribute("Color"));  
      var customerName = attributeCollection.getAttribute("CustomerName");  
      var startTime = app.get_start().format("MMM dd, yyyy HH:mm:ss");  
      attributeCollection.setAttribute("OriginalStartTime", startTime);  
 
      // Set the stateimage  
      var image = document.createElement("img");  
      image.setAttribute("src", '/Images/16x16/icons/' + StateIconName);  
      image.setAttribute("alt", 'IconImage');  
      image.setAttribute("ondragstart", 'javascript:return false;');  
 
      // If the appointment has a substate then show the substateimage  
      if (SubStateIconName != null) {  
        var image2 = document.createElement("img");  
        image2.setAttribute("src", '/Images/16x16/icons/' + SubStateIconName);  
        image2.setAttribute("alt", 'IconImage');  
        image2.setAttribute("ondragstart", 'javascript:return false;');  
      }  
 
      app.set_cssClass("rsCategory" + RsCategory);  
 
      // All appointments with ID 0 are script generated, they are not actually appointments within the database, thus must not be allowed to  
      // be edited/moved or resized in any way shape or form.  
      if (app.get_id() == 0) {  
        app.set_allowDelete(false);  
        app.set_allowEdit(false);  
      }  
 
      var divs = element.getElementsByTagName('div');  
      var result;  
      var innerHTML;  
      for (i = 0; i < divs.length; i++) {  
        // IE and its eternal spacing issues *sigh*  
        if ($telerik.$(divs[i]).is("div.rsAptContent")) {  
          result = divs[i];  
          innerHTML = result.innerHTML;  
          result.innerHTML = '';  
          result.appendChild(image);  
 
          // If the appointment has a substate then show the substateimage  
          if (SubStateIconName != null) { result.appendChild(image2); }  
 
          resultresult.innerHTML = result.innerHTML + innerHTML;  
          resultresult.innerHTML = result.innerHTML + "<br />";  
 
 
          AddTargetControl(app);  
        }  
      }  
    } 
Peter
Telerik team
 answered on 26 Sep 2009
1 answer
146 views
I need to get the equivalent to $find('<%=RadTreeView1.ClientID %>'); in JavaScript. The problem is my treeview is nested within a radpanelbar. Here is the code I have so far but it is not working.

            scheduler = $find('<%=RadScheduler1.ClientID %>');
            panelBar = $find('<%=RadPanelBar1.ClientID %>');
            item = panelBar.findItemByText("Events");
            treeview = item.findControl('<%=RadTreeView1.ClientID %>');

Here is the aspx of the panel bar.
<telerik:RadPanelBar ID="RadPanelBar1" runat="server" Skin="Web20" ExpandMode="SingleExpandedItem"
        AllowCollapseAllItems="false" Width="220px" BorderStyle="None" OnClientItemClicked="itemClicked"
            Height="500px">
            <CollapseAnimation Type="None" Duration="100"></CollapseAnimation>
            <Items>
                <telerik:RadPanelItem runat="server" Text="Events" Font-Bold="true" Font-Size="Medium"
                    Expanded="true">
                    <Items>
                        <telerik:RadPanelItem runat="server">
                            <ItemTemplate>
                                <telerik:RadTreeView ID="RadTreeView1" runat="server" Skin="Web20" CssClass="leftPanelContent"
                                    CheckBoxes="true" OnClientNodeChecking="OnClientNodeChecked" OnClientNodeClicking="OnClientNodeClicking">
                                </telerik:RadTreeView>
                            </ItemTemplate>
                        </telerik:RadPanelItem>
                    </Items>
                </telerik:RadPanelItem>

Thanks,


Yana
Telerik team
 answered on 26 Sep 2009
1 answer
125 views
Hello, I have problem with sending some values from Radwindow to Detailgrid (Radgrid2) with this command:
                    
                    var MasterTable = $find("<%= RadGrid2.ClientID %>").get_masterTableView();  
                    alert( MasterTable.get_id() );
                    MasterTable.fireCommand("InsertEditValue",zobraz + "|" + guid); 
It seems that firecommand working only with one Grid on the page..  
Is there anything what im doing wrong? I have no clue..

<script type ="text/jscript" language="JavaScript" src="../Scripts.js"></script>  
      
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
        <script type="text/javascript">  
            //<![CDATA[
            function openWin()
            {
                var oWnd = radopen(null, "RadWindow1");
            }        
            function OnClientClose(oWnd,args)
            {
                var arg = args.get_argument();
                if(arg)
                { 
                   var guid   = arg.mestoGuid;
                   var zobraz = arg.mestoText;
  
                    var MasterTable = $find("<%= RadGrid2.ClientID %>").get_masterTableView();  
                    alert( MasterTable.get_id() );
                    MasterTable.fireCommand("InsertEditValue",zobraz + "|" + guid); 
                }
            }
            //]]>  
        </script>  
          
    </telerik:RadCodeBlock>     
  
    <telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="False" VisibleStatusbar="False"  
        ReloadOnShow="True" runat="server" Skin="Sunset" Left="" meta:resourcekey="RadWindowManager1Resource1"   
        style="display: none;" Top="">  
        <Windows>  
            <telerik:RadWindow ID="RadWindow1" runat="server" Behaviors="Close" OnClientClose="OnClientClose"   
             Height = "220px" Width = "360px" NavigateUrl="~/Template/Adresy.aspx?UlicaReadOnly=true&CisloDomuReadOnly=true"   
                meta:resourcekey="RadWindow1Resource1" />  
        </Windows>  
    </telerik:RadWindowManager>         
  
<!-- Ajax -->    
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
        <AjaxSettings>  
            <telerik:AjaxSetting AjaxControlID="RadGrid1">  
                <UpdatedControls>                      
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />  
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="RadAjaxLoadingPanel1"/>  
                </UpdatedControls>                  
            </telerik:AjaxSetting>  
        </AjaxSettings>  
        <ClientEvents OnRequestStart="RequestStart" />  
    </telerik:RadAjaxManager>   
 
<!-- MASTER grid -->     
    <cn:CustomGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" OnInit="Set1" CommandItemDisplay="Top" meta:resourcekey="GridView1Resource1" >  
        <ClientSettings allowkeyboardnavigation="true" enablepostbackonrowclick="true">  
            <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" />              
            <Selecting AllowRowSelect="true" />  
        </ClientSettings>             
        <mastertableview datakeynames="JJTE_TYPEN, UZSUS" datasourceid="SqlDataSource1" >  
            <Columns>                                
               ...mastertableviem column...  
            </Columns>  
        </mastertableview>  
    </cn:CustomGrid>  
<br />  
  
<!-- DETAIL grid -->    
    <cn:CustomGrid ID="RadGrid2" runat="server" DataSourceID="SqlDataSource4" OnInit="Set2" CommandItemDisplay="Top" meta:resourcekey="GridView2Resource1" >  
        <ClientSettings allowkeyboardnavigation="true" enablepostbackonrowclick="true">  
            <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" />              
            <Selecting AllowRowSelect="true" />  
        </ClientSettings>    
        <mastertableview datakeynames="JUZS_JJTE_TYPEN, JUZS_UZSUS, GIID_CELOK" datasourceid="SqlDataSource4">  
            <Columns>                      
                <telerik:GridTemplateColumn meta:resourcekey="GridTemplateColumnResource20" ItemStyle-Width ="150px" SortExpression="ADRESA" UniqueName="ADRESA" >  
                    <ItemTemplate>  
                        <%# DataBinder.Eval(Container.DataItem, "MESTO")%>   
                    </ItemTemplate>    
                    <EditItemTemplate>                          
                       <telerik:RadTextBox ID="ADRESA"  runat="server" Width="200px" onclick="openWin(); return false;" AutoPostBack="true" Text='<%# Bind("MESTO") %>' />                      
                    </EditItemTemplate>                        
                </telerik:GridTemplateColumn>  
                  
                <telerik:GridBoundColumn DataField="KRAJ" meta:resourcekey="GridBoundColumnResource21"  
                    SortExpression="KRAJ" UniqueName="KRAJ" ItemStyle-Width ="100px">  
                </telerik:GridBoundColumn>   
                  
            </Columns>  
        </mastertableview>  
    </cn:CustomGrid>           
      
<!-- Data source -->      
    <cn:CustomSqlDataSource ID="SqlDataSource1" runat="server"   
        ConnectionString="<%$ ConnectionStrings:Jishm %>"   
        ProviderName="<%$ ConnectionStrings:Jishm.ProviderName %>"   
        OldValuesParameterFormatString="old_{0}"   
        SelectCommand="SELECT jjus.UZSUS, jjus.SKRATKA, jjus.JJTE_TYPEN ,jjte.SKRATKA jjte_skratka, jjus.POPIS, jjus.POZNAMKA  
                                , jjus.JUZS_JJTE_TYPEN, jjus.JUZS_UZSUS  
                                , jjte2.SKRATKA juzs_jjte_skratka2, jjus2.SKRATKA juzs_skratka2  
                                , jjus.AKTUAL, jj$#pck_funkcie.fn_domena_hodnota('TRUE_FALSE',jjus.AKTUAL,[P_JAZYK]) AKT_P, nvl(JJPO.MENOPRIEZVISKO, 'nepr. ('|| jjus.UZIVATEL ||')') UZIVATEL, jjus.DATUM_DML  
                                , jjus.JUZS_JJTE_TYPEN ||'|'|| jjus.JUZS_UZSUS JJUZ_PK2  
                                , jjte2.SKRATKA  ||' ' ||jjus2.SKRATKA JJTE_JJUZ2  
                        FROM JJUZLSUY jjus  
                           , JJUZLSUY jjus2  
                           , JJTYPENY jjte  
                           , JJTYPENY jjte2  
                           , JJPOUZIVATEL_VIEW JJPO  
                        WHERE jjus.JJTE_TYPEN = jjte.TYPEN  
                        AND jjus.UZIVATEL = JJPO.LOGIN(+)  
                        and jjus.JUZS_JJTE_TYPEN = jjte2.TYPEN(+)  
                        and jjus.JUZS_UZSUS = jjus2.UZSUS(+)  
                        ORDER BY jjus.JJTE_TYPEN, jjus.UZSUS"  
        InsertCommand="INSERT INTO JJUZLSUY( JJTE_TYPEN, UZSUS, SKRATKA, POPIS, JUZS_JJTE_TYPEN, JUZS_UZSUS, POZNAMKA, AKTUAL, UZIVATEL, DATUM_DML )   
                        VALUES ( [JJTE_TYPEN], [UZSUS],[SKRATKA], [POPIS], [JUZS_JJTE_TYPEN], [JUZS_UZSUS], [POZNAMKA], [AKTUAL], [P_USER], SYSDATE )"   
        UpdateCommand="UPDATE JJUZLSUY SET  
                            SKRATKA         = [SKRATKA]  
                          , POPIS           = [POPIS]    
                          , JUZS_JJTE_TYPEN = [JUZS_JJTE_TYPEN]  
                          , JUZS_UZSUS  = [JUZS_UZSUS]  
                          , POZNAMKA    = [POZNAMKA]   
                          , AKTUAL      = [AKTUAL]  
                          , UZIVATEL  = [P_USER]  
                          , DATUM_DML = sysdate  
                        WHERE JJTE_TYPEN = [old_JJTE_TYPEN]  
                        AND UZSUS = [old_UZSUS]"  
        DeleteCommand="DELETE FROM JJUZLSUY WHERE UZSUS = [old_UZSUS] AND JJTE_TYPEN = [old_JJTE_TYPEN]">     
    
        <SelectParameters>   
            <asp:ControlParameter Name="P_JAZYK" ControlID="__Page" PropertyName="Jazyk" Type="String" Size="250" Direction="Input" />   
        </SelectParameters>  
          
        <InsertParameters>  
            <asp:ControlParameter  Name="P_USER" ControlID="__Page" PropertyName="UserName" Type="String" Size="250" />  
            <asp:Parameter Name="JJTE_TYPEN" Type="Int32" Size="2" />  
            <asp:Parameter Name="UZSUS" Type="Int32" Size="2" />    
            <asp:Parameter Name="SKRATKA" Type="String" Size="10" />   
            <asp:Parameter Name="POPIS" Type="String" Size="50" />  
            <asp:Parameter Name="JUZS_JJTE_TYPEN" Type="Int32" Size="2" />  
            <asp:Parameter Name="JUZS_UZSUS" Type="Int32" Size="2" />     
            <asp:Parameter Name="POZNAMKA" Type="String" Size="500" />   
            <asp:Parameter Name="AKTUAL" Type="String" Size="5" />                
        </InsertParameters>          
        <UpdateParameters>  
            <asp:ControlParameter  Name="P_USER" ControlID="__Page" PropertyName="UserName" Type="String" Size="250" />   
            <asp:Parameter Name="old_JJTE_TYPEN" Type="Int32" Size="2" />   
            <asp:Parameter Name="old_UZSUS" Type="Int32" Size="2" />                    
            <asp:Parameter Name="SKRATKA" Type="String" Size="10"  />    
            <asp:Parameter Name="POPIS" Type="String" Size="50"  />   
            <asp:Parameter Name="JUZS_JJTE_TYPEN" Type="Int32" Size="2" />   
            <asp:Parameter Name="JUZS_UZSUS" Type="Int32" Size="2" />   
            <asp:Parameter Name="POZNAMKA" Type="String" Size="500" />    
            <asp:Parameter Name="AKTUAL" Type="String" Size="5" />   
        </UpdateParameters>  
        <DeleteParameters>  
            <asp:ControlParameter Name="old_UZSUS" ControlID="RadGrid1" PropertyName="SelectedValue" Type="Int32" Size="2"  />   
            <asp:ControlParameter Name="old_JJTE_TYPEN" ControlID="RadGrid1" PropertyName="SelectedValue" Type="Int32" Size="2"  />   
        </DeleteParameters>       
                  
    </cn:CustomSqlDataSource>   
      
    <cn:CustomSqlDataSource ID="SqlDataSource2" runat="server"   
        ConnectionString="<%$ ConnectionStrings:Jishm %>"   
        ProviderName="<%$ ConnectionStrings:Jishm.ProviderName %>"   
        SelectCommand="SELECT TYPEN, SKRATKA, POPIS   
                        FROM JJTYPENY   
                        WHERE AKTUAL = 'TRUE' ORDER BY TYPEN">  
    </cn:CustomSqlDataSource>  
          
    <cn:CustomSqlDataSource ID="SqlDataSource4" runat="server"   
        ConnectionString="<%$ ConnectionStrings:Jishm %>"   
        ProviderName="<%$ ConnectionStrings:Jishm.ProviderName %>"  
        OldValuesParameterFormatString="old_{0}"   
        SelectCommand="SELECT  jjuza.JUZS_JJTE_TYPEN  
                        ,jjuza.JUZS_UZSUS  
                        ,rawtoguid(jjuza.GIID_CELOK) GIID_CELOK  
                        , jjuc.KRAJ  
                        , jjuc.MESTO   
                        ,jjuza.AKTUAL  
                        , jj$#pck_funkcie.fn_domena_hodnota('TRUE_FALSE',jjuza.AKTUAL,[P_JAZYK]) AKT_P  
                        , nvl(JJPO.MENOPRIEZVISKO, 'nepr. ('|| jjuza.UZIVATEL ||')') UZIVATEL  
                        ,jjuza.DATUM_DML  
                        FROM JJUZSADR jjuza, JJ_UZEMNY_CELOK_POPIS_VIEW jjuc, JJPOUZIVATEL_VIEW JJPO  
                        WHERE rawtoguid(jjuza.GIID_CELOK) = rawtoguid(jjuc.GUID_CELOK)    
                        AND jjuza.UZIVATEL = JJPO.LOGIN(+)  
                        AND jjuza.JUZS_JJTE_TYPEN = [JJTE_TYPEN]  
                        AND jjuza.JUZS_UZSUS      = [UZSUS]  
                        order by jjuc.CELOK_SKRATKA asc"  
                          
        InsertCommand="INSERT INTO JJUZSADR (JUZS_JJTE_TYPEN, JUZS_UZSUS, GIID_CELOK, AKTUAL, UZIVATEL, DATUM_DML)   
                                    VALUES([JUZS_JJTE_TYPEN], [JUZS_UZSUS], [GIID_CELOK], [AKTUAL], [P_USER], sysdate)"                                       
        OnInserting = "SqlDataSource4_Inserting"                                        
                                      
        UpdateCommand="UPDATE JJUZSADR SET   AKTUAL      = [AKTUAL]  
                                            ,UZIVATEL    = [P_USER]  
                                            ,DATUM_DML   = sysdate  
                                            WHERE JUZS_JJTE_TYPEN = [old_JUZS_JJTE_TYPEN]  
                                            AND JUZS_UZSUS        = [old_JUZS_UZSUS]"                                                                     
  
        DeleteCommand="DELETE FROM JJUZSADR WHERE JUZS_JJTE_TYPEN = [old_JUZS_JJTE_TYPEN]  
                                            AND JUZS_UZSUS        = [old_JUZS_UZSUS]">  
                          
        <SelectParameters>      
            <asp:ControlParameter Name="P_JAZYK" ControlID="__Page" PropertyName="Jazyk" Type="String" Size="250" Direction="Input" />       
            <asp:ControlParameter ControlID="RadGrid1" Name="JJTE_TYPEN" DefaultValue="0" PropertyName="SelectedValues['JJTE_TYPEN']" Type="Int32" />  
            <asp:ControlParameter ControlID="RadGrid1" Name="UZSUS" DefaultValue="0" PropertyName="SelectedValues['UZSUS']" Type="Int32" />  
        </SelectParameters>      
          
        <InsertParameters>  
            <asp:ControlParameter  Name="P_USER" ControlID="__Page" PropertyName="UserName" Type="String" Size="250" />  
            <asp:ControlParameter ControlID="RadGrid1" Name="JUZS_JJTE_TYPEN" DefaultValue="0" PropertyName="SelectedValues['JJTE_TYPEN']" Type="Int32" />  
            <asp:ControlParameter ControlID="RadGrid1" Name="JUZS_UZSUS" DefaultValue="0" PropertyName="SelectedValues['UZSUS']" Type="Int32" />   
            <asp:Parameter Name="GIID_CELOK" Type="String" Size="32" />               
            <asp:Parameter Name="AKTUAL" Type="String" Size="50" />                           
        </InsertParameters>      
          
        <UpdateParameters>  
            <asp:ControlParameter  Name="P_USER" ControlID="__Page" PropertyName="UserName" Type="String" Size="250" />  
            <asp:Parameter Name="AKTUAL" Type="String" Size="50" />    
            <asp:Parameter Name="old_JUZS_JJTE_TYPEN" Type="Int32" />    
            <asp:Parameter Name="old_JUZS_UZSUS" Type="Int32" />                 
        </UpdateParameters>                  
          
        <DeleteParameters>  
            <asp:Parameter Name="old_ODBMIE" Type="String" Size="20" />                
        </DeleteParameters>        
    </cn:CustomSqlDataSource>  
 
 

Tsvetoslav
Telerik team
 answered on 26 Sep 2009
1 answer
251 views

Hello All,

I'm using Telerik's RadWindow/Ajax mechanism for creating Modal Popup
Window. Both Parent and Popup are in separate aspx files and in their own Windows.

I would like to reterieve Data in Modal Popup Window and then return back user's
selecteion from RadGrid into parent Window when Popup is closed.

I have tried Post and changing PostBackUrl and using e.g.
ViewState as transform mechanism but that didn't solve the problem because when
Popup Window was opened using Telerik's Ajax/Javascript methods it needed 
something else to be closed too. Otherwise Popup Window stayed into screen.

I found a sample from Telerik
http://demos.telerik.com/aspnet-ajax/window/examples/dialogreturnvalue/defaultcs.aspx
which used plain Javascript/Ajax? to two windows communication.

So if anyone has any ideas how to transfer data in Collection between to Windows and
especially back I from Modal child Windows I would be glad to here about then.

I know that my approach to this problem might not be the right one so, please give me some detailed information
if you have solved same kind of situation.

Best to All,

Michael

Georgi Tunev
Telerik team
 answered on 26 Sep 2009
1 answer
76 views
In javascript, I disable the RadDatePicker, but it does not gray out the popup Button.

picker.set_enabled(false);

The date input is greyed out, but not the popup button.

How do I visually show that the popup button is disabled?

Thanks for your help!
Pavlina
Telerik team
 answered on 26 Sep 2009
1 answer
102 views
Looking over the template options, I can see a 'entire menu' template, or an 'individual' template options. Is there anyway I can create a few templates that I can then apply to various menu items?
In my menu I want to have some with textboxes, some with calendars, ect.
Instead of having every one with their own template that I'd just start copy and pasting to do, is there a way I could create one and 'assign' it to the menu items?

If there is - Where'd I miss it? :)

If not - Look a feature request. :)
Yana
Telerik team
 answered on 26 Sep 2009
1 answer
38 views
I found this bug and am not sure if it is a RadEditor code bug or a problem with the demo code. This is how to reproduce it.

Go to this page with FireFox (I am using version 3.5.3)

http://demos.telerik.com/aspnet-ajax/editor/examples/customdialogs/defaultcs.aspx

In the editor window select word WYSIWYG and click the first editor button (Insert Special Link). Fill in the dialog and click insert link button. Notice the loss of text before the word WYSIWYG

I need to implement this type of feature and this bug would be a show stopper.
Lini
Telerik team
 answered on 26 Sep 2009
1 answer
133 views
Is it possible to have one?  I simply want a ListBox with lines separating the items in it; but I don't want to make an item template.  I know the RadGrid allows cell borders but haven't seen any examples of a ListBox with them on the website.

Thanks,

Ed Graham
Genady Sergeev
Telerik team
 answered on 26 Sep 2009
1 answer
62 views
Ia m trying to open a window when there is an excetion raised.  Per the documentation you can add a control to the bottom of the grid but this is not user friendly and hardly visible in the example:

I can open the window on the client side and set the public variable but can't actually get that value to the client.

******

So I have the public variable for my class:

Public

 

ERR_DESC As String = ""

 

And set this on the Itemupdate() event:

Protected Sub RadGrid1_ItemUpdated(ByVal source As Object, ByVal e As Telerik.Web.UI.GridUpdatedEventArgs) Handles RadGrid1.ItemUpdated
        If Not e.Exception Is Nothing Then
            e.KeepInEditMode = True
            e.ExceptionHandled = True
            ERR_DESC = e.Exception.Message.ToString
        End If
 End Sub

*****

On the client ERR_DESC has the e.Exception.Message.ToString value when it's binding the server side code to the client-side variable but when the client is written the variable is an empty string.

      Sys.Application.add_load(applicationLoadHandler);

      function applicationLoadHandler() {
        debugger;
     
        var ERR_DESC='<%=ERR_DESC%>';
        if (ERR_DESC!='') {
            var oWnd = radopen("RTS_Message_Window.aspx?message="+ERR_DESC+"&title=Problem Running Report" , "RadWindow1" );
            oWnd.setSize (300, 200);
            oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close);
          }              
        }


What am I missing here??
Tsvetoslav
Telerik team
 answered on 26 Sep 2009
1 answer
300 views
Hello
I have a WebControl Project ,it has many class that Create Dynamic control ,for example TextBox,checkBox and so on.
in my project Generat WebForm via this project and i have a class name "Grid"
in this class I create a RadGrid and Bind to diffrent Table
I want to Insert/Delete/Update via Grid and UserControl
when I Click "Add new Record" in top Grid:NeedDataSource And ItemCommand Event Raised and Load UserControl
but I Click Save Button with "PerformInsert" CommandName just NeedDataSource And ItemCommand Event Raised and InsertCommand Event not raise
Thanks a lot
 public override System.Web.UI.Control GetControl(System.Data.DataRow dr)  
        {  
            ItemData = dr;  
            Telerik.Web.UI.RadAjaxPanel pnl = new Telerik.Web.UI.RadAjaxPanel();  
            //System.Web.UI.WebControls.Panel pnl = new System.Web.UI.WebControls.Panel();  
            pnl.Width = this.Width;              
            pnl.ID = this.ID;  
            pnl.Visible = this.Visible;  
            pnl.Attributes.Add("Style"string.Format("position: absolute;left: {0}px; Top:{1}px;z-index:{2};"this.Left, this.Top , this.zIndex));  
            pnl.Width = this.Width;  
            pnl.Height = this.Height;  
            Telerik.Web.UI.RadGrid _RadGrid = new Telerik.Web.UI.RadGrid();  
            _RadGrid.Width = this.Width;  
            _RadGrid.Height = this.Height;  
            _RadGrid.Visible = this.Visible;  
            _RadGrid.ClientSettings.Scrolling.AllowScroll = true;  
            _RadGrid.ID = "grd_" + this.ID;  
            //_RadGrid.AllowAutomaticInserts = true;  
            //_RadGrid.AllowAutomaticUpdates = true;  
              
            if (!this.ReadOnly)  
            {  
                _RadGrid.MasterTableView.CommandItemDisplay = Telerik.Web.UI.GridCommandItemDisplay.Top;  
                _RadGrid.MasterTableView.CommandItemSettings.AddNewRecordText = "اضافه کردن رکورد جدید";  
                _RadGrid.MasterTableView.CommandItemSettings.RefreshText = "بروز رسانی";  
                _RadGrid.Attributes.Add("Style"string.Format("position: absolute;left: {0}px; Top:{1}px;", 0, 0));  
                _RadGrid.Height = this.Height;  
                //_RadGrid.MasterTableView.EditMode = Telerik.Web.UI.GridEditMode.InPlace;  
              
            }              
            //_RadGrid.MasterTableView.EditFormSettings.PopUpSettings. ZIndex = 15000;  
            _RadGrid.MasterTableView.EditFormSettings.FormStyle.BackColor = System.Drawing.Color.WhiteSmoke;  
             _RadGrid.Skin = "Office2007";  
            _RadGrid.MasterTableView.EditFormSettings.EditFormType = Telerik.Web.UI.GridEditFormType.WebUserControl;  
            //_RadGrid.ClientSettings.ClientEvents.OnPopUpShowing = "PopUpShowing"; // this function must exist in Master Page ;)  
            _RadGrid.MasterTableView.EditFormSettings.UserControlName = "~/FormGeneratorTools/UCLoadForm.ascx";  
            _RadGrid.MasterTableView.DataKeyNames =new string[1]{string.Format("frm{0}Id", BindingFormID)};  
            _RadGrid.NeedDataSource += new GridNeedDataSourceEventHandler(_RadGrid_NeedDataSource);  
            _RadGrid.ItemCommand += new GridCommandEventHandler(_RadGrid_ItemCommand);  
            _RadGrid.InsertCommand += new GridCommandEventHandler(_RadGrid_InsertCommand);  
            _RadGrid.UpdateCommand += new GridCommandEventHandler(_RadGrid_UpdateCommand);  
            _RadGrid.DeleteCommand += new GridCommandEventHandler(_RadGrid_DeleteCommand);  
            AddcolumntoGrid(_RadGrid);  
            _RadGrid.AutoGenerateColumns = false;  
            object objj = _RadGrid.DataSource;  
            pnl.Controls.Add(_RadGrid);  
            return pnl;  
        }  
 
        void _RadGrid_DeleteCommand(object source, GridCommandEventArgs e)  
        {  
            string ID = (e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex][string.Format("frm{0}Id", BindingFormID)].ToString();  
            if (((RadGrid)source).Page.Session["Data_" + BindingFormID] != null)  
            {  
                System.Data.DataSet ds = (System.Data.DataSet)((RadGrid)source).Page.Session["Data_" + BindingFormID];  
                if (ds.Tables[0].Rows.Find(ID) != null)  
                {  
                    ds.Tables[0].Rows.Find(ID).Delete();  
                    ds.Tables[0].AcceptChanges();  
                }  
            }  
        }  
 
        void _RadGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)  
        {  
            System.Data.DataSet ds = new System.Data.DataSet();  
             if (e.RebindReason == GridRebindReason.InitialLoad)  
                 ((RadGrid)source).Page.Session["Data_" + BindingFormID] = GetData();   
 
             if (((RadGrid)source).Page.Session["Data_" + BindingFormID] != null)  
                 ds.Merge((System.Data.DataSet)((RadGrid)source).Page.Session["Data_" + BindingFormID]);  
                   
            if(ds!=null)   
                ((RadGrid)source).DataSource = ds;  
        }          
        void _RadGrid_InsertCommand(object source, GridCommandEventArgs e)  
        {  
             
            GridEditableItem editedItem = e.Item as GridEditableItem;  
            UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);  
            object obj = userControl.FindControl("Co_" + BindingFormID);  
            System.Data.DataSet dsNewData = ((WebForm)obj).GetDate(userControl.Request);  
            string CurrentID = "0";  
            if (userControl.Session["Data_" + BindingFormID] != null)  
            {  
                if((((System.Data.DataSet)userControl.Session["Data_" + BindingFormID])).Tables[0].Rows.Count!=0)  
                    CurrentID = (((System.Data.DataSet)userControl.Session["Data_" + BindingFormID])).Tables[0].Select(string.Format("frm{0}Id > 0", BindingFormID), string.Format("frm{0}Id DESC", BindingFormID))[0][string.Format("frm{0}Id", BindingFormID)].ToString();  
                dsNewData.Tables[0].Rows[0][string.Format("frm{0}Id", BindingFormID)] = long.Parse(CurrentID) + 1;  
                dsNewData.Merge((System.Data.DataSet)userControl.Session["Data_" + BindingFormID]);  
            }  
            else 
                dsNewData.Tables[0].Rows[0][string.Format("frm{0}Id", BindingFormID)] = long.Parse(CurrentID);  
 
            userControl.Session["Data_" + BindingFormID] = dsNewData;  
     
        }  
        /// <summary>  
        ///   
        /// </summary>  
        /// <param name="source"></param>  
        /// <param name="e"></param>  
        void _RadGrid_ItemCommand(object source, GridCommandEventArgs e)  
        {  
            ((Telerik.Web.UI.GridBaseDataList)(source)).Page.Session["FormID"] = BindingFormID;  
        }  
        /// <summary>  
        ///   
        /// </summary>  
        /// <param name="source"></param>  
        /// <param name="e"></param>  
        void _RadGrid_UpdateCommand(object source, GridCommandEventArgs e)  
        {  
 
            GridEditableItem editedItem = e.Item as GridEditableItem;  
            UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);  
            object obj = userControl.FindControl("Co_" + BindingFormID);  
            System.Data.DataSet dsNewData = ((WebForm)obj).GetDate(userControl.Request);  
            string ID = (e.Item as GridEditFormItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex][string.Format("frm{0}Id", BindingFormID)].ToString();  
            if (userControl.Session["Data_" + BindingFormID] != null)  
            {  
                dsNewData.Tables[0].Rows[0][string.Format("frm{0}Id", BindingFormID)] = ID;  
                if(((System.Data.DataSet)userControl.Session["Data_" + BindingFormID]).Tables[0].Rows.Find(ID)!=null)  
                    ((System.Data.DataSet)userControl.Session["Data_" + BindingFormID]).Tables[0].Rows.Find(ID).Delete();  
                ((System.Data.DataSet)userControl.Session["Data_" + BindingFormID]).AcceptChanges();  
                dsNewData.Merge((System.Data.DataSet)userControl.Session["Data_" + BindingFormID]);  
            }  
            userControl.Session["Data_" + BindingFormID] = dsNewData;  
              
        } 
Tsvetoslav
Telerik team
 answered on 26 Sep 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?