OnItemCreated not called

4 posts, 0 answers
  1. Sandeep
    Sandeep avatar
    22 posts
    Member since:
    Apr 2013

    Posted 21 Aug 2014 Link to this post


    Hi Team,

    I am using treelist. I am binding data to treelist and calling below method

    <ClientSettings>
                                <ClientEvents OnItemDeselected="ReviewerAssignmentList_OnItemDeselected"  OnItemSelected="ReviewerAssignmentList_OnItemSelected"
                                     OnItemCreated="ReviewerAssignmentList_OnItemCreated" />
                                <Selecting AllowItemSelection="true" UseSelectColumnOnly="true" />
                                <Scrolling AllowScroll="true" ScrollHeight="431px" UseStaticHeaders="true" />
                            </ClientSettings>

    Data is binded to treelist.

    And in method ReviewerAssignmentList_OnItemCreated

    function ReviewerAssignmentList_OnItemCreated(sender, args) {               
                    alert('1');               
                }

    It is not called method ReviewerAssignmentList_OnItemCreated, but If I click anywhere on page this method is called and displays alert.

    Could any body help me on this, so that alert is displayed when rows are created.

    Regards
    Sandy
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 21 Aug 2014 in reply to Sandeep Link to this post

    Hi Sandeep,

    The provided information is not enough to replicate the issue. The OnItemCreated event of RadTreeList will fire when each of the TreeListDataItem client components is created. Note that the RadTreeList client TreeListDataItem objects will not be created until they are requested, for example by calling TreeListInstance.get_dataItems(). Until then, the OnItemCreated client event of the control will not fire. Please have a look into this online demo for knowing the working of client side events of RdaTreeList.

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sandeep
    Sandeep avatar
    22 posts
    Member since:
    Apr 2013

    Posted 22 Aug 2014 in reply to Princy Link to this post

    Hi Princy,

    I have a RadToolbar and TreeList.

    When I bind the data to treelist, select a row.

    And click on radtoolbar button "Update", then the selected row in displayed in editable mode.

    but the child items of selected row are not selected by default.

    <telerik:RadToolBar ID="ReviewerObjectToolBar" runat="server" Enabled='<%# EnableToolBar()%>' OnClientButtonClicking="onReviewerToolBarClicking"
                            OnButtonClick="ReviewerObjectToolBar_Click" ToolTip='<%#ScopeToolTip %>' BorderStyle="None"
                            Width="100%" Height="28px">
                            <Items>
                                <telerik:RadToolBarButton ImageUrl="~/client/Images/4x_rediscover.png" Value="Rediscover"
                                    Enabled='<%# EnableRediscoverButton %>' ToolTip='<%# RediscoverToolTip%>' CommandName="Rediscover" />                             
                                <telerik:RadToolBarButton ImageUrl="~/client/Images/edit.png" Value="btnUpdateSelectedClick"
                                    Enabled="false" CommandName="UpdateSelected"  />
                                <telerik:RadToolBarButton ImageUrl="~/client/Images/Save.png" Value="btnSaveClick"
                                    Text="Save" Visible="false" CommandName="SaveSelected"/>
                                <telerik:RadToolBarButton ImageUrl="~/client/Images/cancel1.png" Value="btnCancelClick"
                                    Text="Cancel" Visible="false" CommandName="Cancel" />
                            </Items>
                        </telerik:RadToolBar>
    <telerik:RadTreeList ID="ReviewerAssignmentList" runat="server" DataKeyNames="ObjectId" ClientDataKeyNames="AssignmentId" OnPreRender="RadTreeList_PreRender"
                            EditMode="InPlace" OnItemCreated="ReviewerAssignmentList_ItemCreated" AllowMultiItemSelection="True"
                            AllowLoadOnDemand="true" ParentDataKeyNames="ParentObjectId" Width="100%" AllowPaging="true" PageSize="15"
                            AllowMultiItemEdit="true" OnUpdateCommand="ReviewerAssignmentList_UpdateCommand" AllowSorting="true"
                            OnItemDataBound="ReviewerAssignmentList_ItemDataBound"
                            GridLines="Both" AutoGenerateColumns="false" OnNeedDataSource="ReviewerAssignmentList_NeedDataSource"  
                            OnChildItemsDataBind="ReviewerAssignmentList_ChildItemsDataBind" OnItemCommand="ReviewerAssignmentList_ItemCommand">
                            <HeaderStyle Height="33px"/>
                            <Columns></Columns>
                            <ClientSettings>
                                <ClientEvents OnItemDeselected="ReviewerAssignmentList_OnItemDeselected"  OnItemSelected="ReviewerAssignmentList_OnItemSelected"
                                     OnItemCreated="ReviewerAssignmentList_OnItemCreated" />
                                <Selecting AllowItemSelection="true" UseSelectColumnOnly="true" />
                                <Scrolling AllowScroll="true" ScrollHeight="431px" UseStaticHeaders="true" />
                            </ClientSettings>
                            <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" />
                        </telerik:RadTreeList>



    <script type="text/javascript">
                function ReviewerAssignmentList_OnItemCreated(sender, args) {                 
                    var id1 = args.get_item().get_dataKeyValue("AssignmentId");                
                    if (Reviewerselected[id1] && id1 != -1) {
                        args.get_item().set_selected(true);
                        document.getElementById('<%=ReviewerEditableItem.ClientID%>').value = ".";
                    }
                }

    function ReviewerAssignmentList_OnItemSelected(sender, eventArgs) {
                    var id = eventArgs.get_item().get_dataKeyValue("AssignmentId");
                    if (!Reviewerselected[id] && id != -1 ) {
                        Reviewerselected[id] = true;
                        document.getElementById('<%=ReviewerEditableItem.ClientID%>').value = document.getElementById('<%=ReviewerEditableItem.ClientID%>').value + "," + id;
                    }
                }

    function ReviewerAssignmentList_OnItemDeselected(sender, eventArgs) {
                    //var id = eventArgs.get_item().get_dataKeyValue("AssignmentId");
                    //if (Reviewerselected[id]) {
                    //    Reviewerselected[id] = null;
                    //}

                    var assignmentId = eventArgs.get_item().get_dataKeyValue("AssignmentId");
                    var selectedRows = document.getElementById('<%=ReviewerEditableItem.ClientID%>').value;
                    if (Reviewerselected[assignmentId]) {
                        Reviewerselected[assignmentId] = null;
                        var rplStr = ',' + assignmentId;
                        var intIndexOfMatch = selectedRows.indexOf(',' + assignmentId);
                        while (intIndexOfMatch != -1) {
                            // Relace out the current instance.                         
                            selectedRows = selectedRows.replace(',' + assignmentId, '');
                            // Get the index of any next matching substring.
                            intIndexOfMatch = selectedRows.indexOf(',' + assignmentId);
                        }
                        document.getElementById('<%=ReviewerEditableItem.ClientID%>').value = selectedRows;

                    }
    }
            </script>

    Do I need to do something else also

    Please help.

    Regards,
    Sandeep
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 29 Aug 2014 in reply to Sandeep Link to this post

    Hi Sandeep,

    I guess you want to select a child node on selection of parent node and deselect also. Please have a look into this forum thread which discuss the same scenario.

    Thanks,
    Princy.
Back to Top