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

batchediting not able to go through e.item isineditmode

6 Answers 144 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rajshree
Top achievements
Rank 1
Rajshree asked on 05 May 2015, 04:03 AM

 

 I need to add tooltip in edittampleate item.i am not able to see the tooltip while i hoverover. also i am using mouseover edit mode.please help. should display= high, medium, etc in tooltip. (dynamic value stored in db)

 

 <telerik:RadGrid ID="gridPersRating" GridLines="None" runat="server" AllowAutomaticDeletes="false" Width="100%" 
            AllowAutomaticInserts="True"  OnItemDeleted="gridPersRating_ItemDeleted" OnItemInserted="gridPersRating_ItemInserted"
            OnItemUpdated="gridPersRating_ItemUpdated" OnPreRender="gridPersRating_PreRender" AllowAutomaticUpdates="True" MasterTableView-TableLayout="Fixed" 
            AutoGenerateColumns="False" OnBatchEditCommand="gridPersRating_BatchEditCommand" OnNeedDataSource="gridPersRating_NeedDataSource" OnItemDataBound="gridPersRating_ItemDataBound" >
            <MasterTableView CommandItemDisplay="Top" DataKeyNames="ID" Font-Size="Small" CommandItemSettings-ShowAddNewRecordButton="false" CommandItemSettings-ShowRefreshButton="false"
                HorizontalAlign="NotSet" EditMode="Batch" AutoGenerateColumns="False">
                <BatchEditingSettings EditType="Cell" OpenEditingEvent="MouseOver" />

<%--                <SortExpressions>
                    <telerik:GridSortExpression FieldName="PerspModel_ID" SortOrder="Descending" />
                </SortExpressions>--%>
                <Columns>
                      <telerik:GridBoundColumn DataField="Perspective_ID" Display="false"  HeaderText="Perspective_ID" 
                        UniqueName="Perspective_ID">
                    </telerik:GridBoundColumn>
                     <telerik:GridBoundColumn DataField="PerspModel_ID" Display="false"  HeaderText="PerspModel_ID" 
                        UniqueName="PerspModel_ID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Hint" Display="false"   HeaderText="Sub-Perspective" SortExpression="Hint"
                        UniqueName="Hint">
                    </telerik:GridBoundColumn>

                     <telerik:GridBoundColumn DataField="HintSubPerspective" ReadOnly="true" HeaderStyle-Width="160px" ItemStyle-Width="160px" HeaderText="Sub-Perspective"
                        UniqueName="HintSubPerspective">
                    </telerik:GridBoundColumn>

                    <telerik:GridBoundColumn DataField="Question" ReadOnly="true"  HeaderStyle-Width="250px" ItemStyle-Width="250px"  HeaderText="Question" SortExpression="Question"
                        UniqueName="Question">
                    </telerik:GridBoundColumn>
                  <%--  <telerik:GridRatingColumn AllowRatingInViewMode="false" HeaderText="Original Rating"  HeaderStyle-Width="130px" ItemStyle-Width="130px" DataField="OriginalRating" UniqueName="OriginalRating"></telerik:GridRatingColumn>
                   --%>
                     <%--<telerik:GridRatingColumn AllowRatingInViewMode="false"  HeaderText="Perspective Rating" HeaderStyle-Width="130px" ItemStyle-Width="130px" DataField="PerspectiveRating" UniqueName="PerspectiveRating"></telerik:GridRatingColumn>--%>
                   <telerik:GridTemplateColumn ColumnEditorID="Original Rating" HeaderStyle-Width="150px" ItemStyle-Height="50px" ItemStyle-Width="150px" UniqueName="OriginalRating"   HeaderText="Original Rating">
                        <ItemTemplate>

                            <telerik:RadRating ID="txtOriginalRating"    HeaderStyle-Width="130px" ItemStyle-Width="130px"   DbValue='<%# DataBinder.Eval(Container.DataItem, "OriginalRating") %>'   runat="server" ></telerik:RadRating>
                        </ItemTemplate>
                        <EditItemTemplate>
                             <telerik:RadRating ID="txtEditOriginalRating"  HeaderStyle-Width="130px" ItemStyle-Width="130px"  DbValue='<%# DataBinder.Eval(Container.DataItem, "OriginalRating") %>'  runat="server" >
                                 <Items>
                                   <telerik:RadRatingItem Value="1" />
                                   <telerik:RadRatingItem Value="2" />
                                   <telerik:RadRatingItem Value="3" />
                                   <telerik:RadRatingItem Value="4" />
                                   <telerik:RadRatingItem Value="5" />
                               </Items>
                             </telerik:RadRating>

                             </EditItemTemplate>

                    </telerik:GridTemplateColumn>

                     <telerik:GridTemplateColumn ColumnEditorID="Perspective Rating" HeaderStyle-Width="150px" ItemStyle-Height="50px" ItemStyle-Width="150px" UniqueName="PerspectiveRating"  HeaderText="Perspective Rating">
                        <ItemTemplate>

                            <telerik:RadRating ID="txtPerspectiveRating"   HeaderStyle-Width="130px" ItemStyle-Width="130px"   DbValue='<%# DataBinder.Eval(Container.DataItem, "PerspectiveRating") %>'   runat="server" ></telerik:RadRating>
                        </ItemTemplate>
                        <EditItemTemplate>
                             <telerik:RadRating ID="txtEditPerspectiveRating"   HeaderStyle-Width="130px" ItemStyle-Width="130px"  DbValue='<%# DataBinder.Eval(Container.DataItem, "PerspectiveRating") %>'  runat="server" ></telerik:RadRating>

                             </EditItemTemplate>

                    </telerik:GridTemplateColumn>

                    <telerik:GridTemplateColumn ColumnEditorID="Comments" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="250px" ItemStyle-Height="50px" ItemStyle-Width="250px"  HeaderText="Comments">
                        <ItemTemplate>
                            <telerik:RadTextBox ID="txtComment" Height="50px"   Wrap="true" Width="240px" TextMode="MultiLine"  EmptyMessage='<%# Eval("DefaultComment")%>' runat="server" Text='<%# Eval("Comments")%>'></telerik:RadTextBox>
                        </ItemTemplate>
                        <EditItemTemplate>
                             <telerik:RadTextBox ID="txtEditComment"  Height="50px"  Wrap="true" Width="240px" TextMode="MultiLine"    runat="server" Text='<%# Eval("Comments")%>'></telerik:RadTextBox>

                             </EditItemTemplate>

                    </telerik:GridTemplateColumn>
                     <%--<telerik:GridTemplateColumn HeaderText="Category" DefaultInsertValue="Beverages" HeaderStyle-Width="150px" UniqueName="CategoryID" DataField="CategoryID">
                        <ItemTemplate>
                            <%# Eval("CategoryName") %>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadDropDownList runat="server" ID="CategoryIDDropDown" DataValueField="CategoryID"
                                DataTextField="CategoryName" DataSourceID="SqlDataSource2">
                            </telerik:RadDropDownList>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>--%>
                  <%--  <telerik:GridNumericColumn DataField="UnitsInStock" HeaderStyle-Width="80px" HeaderText="Units In Stock"
                        SortExpression="UnitsInStock" UniqueName="UnitsInStock">
                    </telerik:GridNumericColumn>
                    <telerik:GridCheckBoxColumn DataField="Discontinued" HeaderStyle-Width="80px" HeaderText="Discontinued" SortExpression="Discontinued"
                        UniqueName="Discontinued">
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridTemplateColumn HeaderText="UnitPrice" HeaderStyle-Width="80px" SortExpression="UnitPrice" UniqueName="TemplateColumn"
                        DataField="UnitPrice">
                        <ItemTemplate>
                            <asp:Label runat="server" ID="lblUnitPrice" Text='<%# Eval("UnitPrice", "{0:C}") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <span>
                                <telerik:RadNumericTextBox Width="55px" runat="server" ID="tbUnitPrice">
                                </telerik:RadNumericTextBox>
                                <span style="color: Red">
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
                                        ControlToValidate="tbUnitPrice" ErrorMessage="*Required" runat="server" Display="Dynamic">
                                    </asp:RequiredFieldValidator>
                                </span>
                            </span>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" HeaderText="Delete" HeaderStyle-Width="50px" ButtonType="ImageButton"
                        CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                    </telerik:GridButtonColumn>--%>
                </Columns>
            </MasterTableView>
            <ClientSettings AllowKeyboardNavigation="true">
                  <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" FrozenColumnsCount="2"></Scrolling>
                <ClientEvents OnBatchEditCellValueChanging="RadGridAdditions_OnBatchEditCellValueChanging" />
            </ClientSettings>
        </telerik:RadGrid>

        </telerik:RadAjaxPanel>

 

 

 

  protected void gridPersRating_ItemDataBound(object sender, GridItemEventArgs e)
        {

            
            
            if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode)
            {                   
              
            //    GridDataItem item1 = e.Item as GridDataItem;
                GridEditableItem item = e.Item as GridEditableItem;
                int id1 = Convert.ToInt32(item["PerspModel_ID"].Text);
                RadRating rating12 = item.FindControl("txtEditOriginalRating") as RadRating;
                // rating.ItemBinding..ToolTip = Math.Round(ratio * 100, 0).ToString() + "%";
                rating12.ItemBinding.ValueField = "Value";
                rating12.ItemBinding.ToolTipField = "ToolTip";

                rating12.DataSource = SurveyModel.GetPerspectiveRatingCriteriaById(id1);
                rating12.DataBind();


                RadRating rating11 = item.FindControl("txtEditPerspectiveRating") as RadRating;
                // rating.ItemBinding..ToolTip = Math.Round(ratio * 100, 0).ToString() + "%";
                rating11.ItemBinding.ValueField = "Value";
                rating11.ItemBinding.ToolTipField = "ToolTip";

                rating11.DataSource = SurveyModel.GetPerspectiveRatingCriteriaById(id1);
                rating11.DataBind();
          }
           
            if (e.Item is GridDataItem)
            {
                GridDataItem dataItem1 = e.Item as GridDataItem;
                
                int id = Convert.ToInt32(dataItem1["PerspModel_ID"].Text);
                RadRating rating = dataItem1.FindControl("txtOriginalRating") as RadRating;
               // rating.ItemBinding..ToolTip = Math.Round(ratio * 100, 0).ToString() + "%";
                rating.ItemBinding.ValueField = "Value";
                rating.ItemBinding.ToolTipField = "ToolTip";

                rating.DataSource = SurveyModel.GetPerspectiveRatingCriteriaById(id);
                rating.DataBind();

                RadRating rating1 = dataItem1.FindControl("txtPerspectiveRating") as RadRating;
                // rating.ItemBinding..ToolTip = Math.Round(ratio * 100, 0).ToString() + "%";
                rating1.ItemBinding.ValueField = "Value";
                rating1.ItemBinding.ToolTipField = "ToolTip";

                rating1.DataSource = SurveyModel.GetPerspectiveRatingCriteriaById(id);
                rating1.DataBind();

               
            }
        }

6 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 07 May 2015, 12:03 PM
Hello Rajshree,

With Batch Editing, when you open an item for editing, no server-side event will be fired (which is the case with the other edit modes). Furthermore, there is only one editor generated for each column and not for each cell.

Since the Batch Editing is a client-side oriented edit mode and the generated editor for the cell will be moved through the currently edited cell, the only possible approach for achieving such customization for the EditItemTemplate would be to handle the OnBatchEditOpened event of the grid and manually display a tooltip with the information that you want. You might need to set the relevant data fields in the ClientDataKeyNames collection of the MasterTableView, so you can retrieve them within the OnbatchEditOpened event.

Detailed information on the client-side API of the BatchEditingManager could be found in the following help article:
Hope this helps.


Regards,
Konstantin Dikov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Rajshree
Top achievements
Rank 1
answered on 07 May 2015, 07:25 PM

is there a way i can get clientkeyvalues in onclientload event? or can i find it from another function and then call it in to onclientload function??

  function OnClientLoad(sender, args) {
               
                 var itemData = sender.get_itemData();
                 for (i in itemData) {
                     itemData[i].tooltip = rating[itemData[i].index];
                 }
             }
</script>

0
Rajshree
Top achievements
Rank 1
answered on 08 May 2015, 03:31 AM
also can you please provide me sample example that you mentioned. ?
0
Konstantin Dikov
Telerik team
answered on 12 May 2015, 12:58 PM
Hi Rajshree,

I have once again gone through your exact requirement and I have to say that it may not be possible to achieve this with Batch Editing, especially if you need to change the ToolTip values for each record.

Generally, if the ToolTips will be the same for each row, you can handle the server-side OnPreRender event of the grid, get reference to the RadRating control and configure it (and set the DataSource property) as shown below:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    GridTableView masterTable = (sender as RadGrid).MasterTableView;
    GridColumn originalRating = masterTable.GetColumnSafe("OriginalRating") as GridColumn;
    GridTemplateColumnEditor originalRatingColumnEditor = (masterTable.GetBatchColumnEditor(originalRating) as GridTemplateColumnEditor);
    RadRating rating11 = originalRatingColumnEditor.ContainerControl.FindControl("txtEditOriginalRating") as RadRating;
 
    DataTable table = new DataTable();
    table.Columns.Add("Value", typeof(int));
    table.Columns.Add("ToolTip", typeof(string));
 
    for (int i = 0; i < 5; i++)
    {
        table.Rows.Add(i, "Some tooltip" + i);
    }
 
     rating11.ItemBinding.ValueField = "Value";
     rating11.ItemBinding.ToolTipField = "ToolTip";
 
     rating11.DataSource = table;
     rating11.DataBind();
}

However, if the tooltips will be changed for each record, you will have to find a way for passing those values to the client, handle the client-side OnBatchEditOpened event of the grid, get reference to the RadRating control and manually change the tooltips of each item.



Regards,
Konstantin Dikov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Rajshree
Top achievements
Rank 1
answered on 15 May 2015, 03:48 PM

here i have managed the functionality- i am able to display dynamic tooltip for each star for each record in grid client side.

                     

                  <ClientEvents OnBatchEditOpened="BatchEditOpened” />
 
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
       <script type="text/javascript">
           function BatchEditOpened(sender, args) {
               var row = args.get_row();
               
               var columnUniqueName = args.get_columnUniqueName();
                
               var rowIndex = row.sectionRowIndex;
               var firstDataItem = $find("<%=grid.ClientID %>").get_masterTableView().get_dataItems()[rowIndex];
              
               if (columnUniqueName == "xyz") {
                    
                   var v = args.get_cell("xyz");
                  var p = v.childNodes[1].childNodes[1].control;
                  
                  var itemData = p.get_itemData();
                  
                  itemData[0].tooltip = firstDataItem.getDataKeyValue("RatingFactor1");
                  itemData[1].tooltip = firstDataItem.getDataKeyValue("RatingFactor2");
                  itemData[2].tooltip = firstDataItem.getDataKeyValue("RatingFactor3");
                  itemData[3].tooltip = firstDataItem.getDataKeyValue("RatingFactor4");
                  itemData[4].tooltip = firstDataItem.getDataKeyValue("RatingFactor5");
                  
               }
 
           }

0
Konstantin Dikov
Telerik team
answered on 20 May 2015, 07:46 AM
Hi Rajshree,

I am glad to see that you were able to implement this on your side and storing the tooltip values for each item in the ClientDataKeyNames collection is the approach that I would personally prefer for this requirement.


Kind Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Rajshree
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Rajshree
Top achievements
Rank 1
Share this question
or