Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
430 views

I have a RadGrid in batch edit mode, cell edit.  I'm using the events 'OnBatchEditOpened' to manipulate some of the UI before the user gets to see/use it and then 'BatchEditCellValueChanged' to run further logic.

 

I have a pair of cells in the grid, in column X, that need to be the opposite of each other's selections in the rad comboBox I'm using in the editor.  If one cell has optionA selected in row A then the other cell needs to show optionB in row B.  The issue I'm running into is that to change cell values I have been using this method:

    batchManager.changeCellValue(cellToChange, valueToUse).

This works fine...normally when I'm updating values in some OTHER grid.  But when I run this logic from the 'BatchEditCellValueChanged' method of the SAME GRID then the grid gets a bit wonky.  I already have code to avoid recursive looping.  The problem is that the grid has a set of functions that are fired in a set sequence, like opening, opened, changing, changed, closing, closed, etc.  When you cause that data flow to step INTO itself before the first is finished... it winds up leaving the edit control visible in the starting cell.

So - CellA opens in editor, I select the radComboBox option A and tab out of the cell.  This causes Telerik's event chain to start firing... it gets to 'BatchEditCellValueChanged' and runs my code.  My code then tell the SAME grid to update CellB in the other row... and that starts the grid's event chain to START OVER... before CellA's 'value changed' event is finished.  I think this is what is causing the logic issues and is making the editor, i.e. the radComboBox in CellA, to remain visible even after I exit the cell.

 

So - all that being said.  What is the 'correct' way to change cellB's in row B when cellA's value changes in rowA of the same batch edit grid?

 

Marin Bratanov
Telerik team
 answered on 07 Jun 2018
2 answers
214 views

I am attempting to place a confirm delete prompt message on a RadButton in a GridTemplateColumn.  Depending on the browser, I am getting mixed results, none of which are acceptable.

In Edge and Chrome, Pressing the delete button pops the message up, but pressing Ok or Cancel will pop the message up second time immedately, and pressing Ok or Cancel on the second message will perform the action desired (Cancel will close message and do nothing, Ok will fire DeleteCommand on server side)

In IE11, pressing the Ok or Cancel will show the confirm message only once.  Ok will run the DeleteCommand routine as expected.  However, Cancel will ignore the cancel and ALSO run the DeleteCommand routine.  

My guess is whatever is causing the issue to show a double-message in Edge or Chrome is being ignored in IE and it just fires the delete command regardless of what button was pressed on the confirm message.

Here are some code snippets:

GRID:

    <telerik:RadGrid OnItemCreated="RadGrid1_ItemCreated" ID="RadGrid1" runat="server" Skin="Simple" AllowPaging="True" AllowSorting="true" >
        <ClientSettings>
            <Scrolling AllowScroll="true" UseStaticHeaders="True" SaveScrollPosition="true" ScrollHeight="415px"></Scrolling>
        </ClientSettings>
        <PagerStyle Mode="NumericPages"></PagerStyle>
        <MasterTableView AutoGenerateColumns="False" DataKeyNames="CapitalProjectID" ClientDataKeyNames="CapitalProjectID" TableLayout="Fixed"
            Width="100%" CommandItemDisplay="Top" PageSize="100" AllowPaging="true" PagerStyle-AlwaysVisible="true" >
            <Columns>
                <%--<telerik:GridButtonColumn ButtonType="ImageButton" UniqueName="RecordStatus" HeaderStyle-Width="3%"  />--%>
                <telerik:GridTemplateColumn HeaderStyle-Width="3%">
                    <ItemTemplate>
                        <asp:Image ID="RecordStatus" runat="server" ImageUrl="/images/spacer.gif" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <%--<telerik:GridButtonColumn ButtonType="ImageButton" UniqueName="PartnerStatus" HeaderStyle-Width="3%"  />--%>
                <telerik:GridTemplateColumn HeaderStyle-Width="3%">
                    <ItemTemplate>
                        <asp:Image ID="PartnerStatus" runat="server" ImageUrl="/images/spacer.gif" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="cpNumber" HeaderText="Project Number" HeaderStyle-Width="15%" />
                <telerik:GridBoundColumn DataField="cpStatus" HeaderText="Status" HeaderStyle-Width="8%" />
                <telerik:GridBoundColumn DataField="SchoolName" HeaderText="School" HeaderStyle-Width="20%" />
                <telerik:GridBoundColumn DataField="cpName" HeaderText="Project Name" HeaderStyle-Width="25%" />
                <telerik:GridBoundColumn DataField="CPPartnershipProject" HeaderText="Partnership" HeaderStyle-Width="9%" />
                <telerik:GridTemplateColumn UniqueName="TemplateEditColumn" HeaderStyle-Width="15%">
                    <ItemTemplate>
                        <telerik:RadButton runat="server" ID="EditButton" Text="EDIT" Skin="ARButton" Width="40px" EnableEmbeddedSkins="false" RenderMode="Lightweight" Visible="true"  />
                        <telerik:RadButton runat="server" ID="DeleteButton" Text="DELETE" CommandName="Delete" Skin="ARButton" Width="50px" EnableEmbeddedSkins="false" RenderMode="Lightweight" Visible="true"  />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="CapitalProjectID" HeaderText="ID" ReadOnly="True"
                    SortExpression="CapitalProjectID" UniqueName="CapitalProjectID" Display="false" >
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="CPProjectStatus" HeaderText="Status" Display="false" />
                <telerik:GridBoundColumn DataField="ShowHandshake" HeaderText="Status" Display="false" />
            </Columns>
            <CommandItemTemplate>
                <div style="vertical-align: text-bottom; padding: 5px 5px;">
                    <asp:Table ID="Table1" runat="server" Width="100%">
                        <asp:TableRow>
                            <asp:TableCell HorizontalAlign="Left"><asp:LinkButton ID="lnkAddNew" runat="server" OnClientClick="ShowInsertForm();"><img style="border:0px;vertical-align:middle;" alt="" src="/images/AddRecord.png"/>&nbsp;New Project</asp:LinkButton></asp:TableCell>
                            <asp:TableCell HorizontalAlign="Left"><asp:LinkButton ID="lnkFilter" runat="server" OnClientClick="FilterForm();"><img style="border:0px;vertical-align:middle;" alt="" src="/images/filter.gif"/>&nbsp;Filter List</asp:LinkButton></asp:TableCell>
                            <asp:TableCell HorizontalAlign="Right"><asp:LinkButton ID="lnkRefresh" runat="server" CommandName="RebindGrid"><img style="border:0px;vertical-align:middle;" alt="" src="/images/Refresh.png"/>&nbsp;Refresh</asp:LinkButton></asp:TableCell>
                        </asp:TableRow>
                    </asp:Table>
                </div>
            </CommandItemTemplate>
        </MasterTableView>
        <ClientSettings>
            <Selecting AllowRowSelect="true"></Selecting>
            <ClientEvents OnRowDblClick="RowDblClick"></ClientEvents>
        </ClientSettings>
    </telerik:RadGrid>

 

SERVER SIDE:

    Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles RadGrid1.ItemCreated
        If TypeOf e.Item Is GridDataItem Then
                Dim deleteButton As RadButton = DirectCast(e.Item.FindControl("DeleteButton"), RadButton)
                Dim msg As String = "'Are you sure you want to delete this project ?'"
                If Not e.Item.DataItem Is Nothing Then
                        msg = [String].Format("'Are you sure you want to delete {0} ?'", DirectCast(e.Item.DataItem, ARKAPP.BusinessLogicLayer.CapitalProject).CPNumber)
                End If
                msg = "if (!confirm(" & msg & ")) {return false;}"
                deleteButton.Attributes("onclick") = msg
        End If
    End Sub

 

    Protected Sub RadGrid1_DeleteCommand(ByVal source As Object, ByVal e As GridCommandEventArgs) Handles RadGrid1.DeleteCommand
        Try
            Dim iProjectID As Integer = DirectCast((DirectCast(e.Item, GridDataItem)).GetDataKeyValue("CapitalProjectID"), Integer)
            SqlHelper.ExecuteNonQuery(System.Configuration.ConfigurationManager.AppSettings(ARKAPP.Web.[Global].CfgKeyConnString), "sp_WA_Del_CapitalProject", iProjectID)
        Catch ex As Exception
            Dim sMsg As String = "ERROR DELETING PROJECT FROM GRID: " & ex.Message
            Document.DeleteLog(sMsg, 0, 0)
            ShowErrorMessage(ex.Message)
        End Try
    End Sub

Mark
Top achievements
Rank 1
 answered on 07 Jun 2018
2 answers
88 views

I have RadGrid with EditMode="Batch". I have two columns Location and Department  and comboboxes Location and Department inside  EditItemTemplate and InsertItemTemplate. They use SqlDataSource, Location data source just query all the location records, department  data source has parameter - location id.

 

I need to be able to update data source of Department in edit and insert mode  depending on what is  selected in the column "location". I created hidden control that is used by department data source, but can't figure out when and how to set it to rebind the Department combobox.

 

Any help is greatly appreciated!

 <asp:HiddenField ID="hflocationid" runat="server" />

<telerik:RadGrid ID="RadGrid3" runat="server" DataSourceID="dsCatGroup" AllowAutomaticDeletes="true"
                        GroupPanelPosition="Top" ResolvedRenderMode="Classic" OnBatchEditCommand="RadGrid2_BatchEditCommand">
                        
                        <MasterTableView AutoGenerateColumns="False" DataKeyNames="PartCatGroupID" EditMode="Batch" CommandItemDisplay="Top"
                            DataSourceID="dsCatGroup" ShowHeadersWhenNoRecords="true">
                            <BatchEditingSettings EditType="Row"  />

                            <Columns>
                                <telerik:GridTemplateColumn HeaderText="Responsible Location" UniqueName="ResponsibleLocation" DataField="ResponsibleLocation" HeaderStyle-Width="125px" AllowFiltering="true" ShowFilterIcon="false" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" FilterControlWidth="250px">
                                                <ItemTemplate>
                                                   <%# Eval("ResponsibleLocation")%>
                                                </ItemTemplate>
                                                <EditItemTemplate>
                                                     <telerik:RadComboBox ID="ddResponsibleLocation1" Runat="server" DataSourceID="dsResponsibleLocations"
                                                                DataTextField="LocationName" DataValueField="LocationId" EmptyMessage="Select a Location"
                                                                EnableAutomaticLoadOnDemand="True" ItemsPerRequest="20" MarkFirstMatch="True"
                                                                ShowMoreResultsBox="True" Width="95%" AutoPostBack="False" ZIndex="20000"
                                                                CausesValidation="False">
                                                            </telerik:RadComboBox>                       
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <telerik:RadComboBox ID="ddResponsibleLocation2" Runat="server" DataSourceID="dsResponsibleLocations"
                                                                DataTextField="LocationName" DataValueField="LocationId" EmptyMessage="Select a Location"
                                                                EnableAutomaticLoadOnDemand="True" ItemsPerRequest="20" MarkFirstMatch="True"
                                                                ShowMoreResultsBox="True" Width="95%" AutoPostBack="False" ZIndex="20000"
                                                                CausesValidation="False">
                                                            </telerik:RadComboBox>
                                                                                 
                                                </InsertItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Responsible Department" UniqueName="ResponsibleDepartment" DataField="ResponsibleDepartment" HeaderStyle-Width="125px" AllowFiltering="true" ShowFilterIcon="false" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" FilterControlWidth="250px">
                                                <ItemTemplate>
                                                   <%# Eval("ResponsibleLocation")%>
                                                </ItemTemplate>
                                                <EditItemTemplate>
                                                     <telerik:RadComboBox ID="ddResponsibleDepartment1" Runat="server" DataSourceID="dsResponsibleDepartments"
                                                                DataTextField="DepartmentCode" DataValueField="DepartmentId" EmptyMessage="Select a Department"
                                                                EnableAutomaticLoadOnDemand="True" ItemsPerRequest="20" MarkFirstMatch="True"
                                                                ShowMoreResultsBox="True" Width="95%" AutoPostBack="False" ZIndex="20000" OnItemDataBound="ddResponsibleDepartment1_ItemDataBound"
                                                                CausesValidation="False">
                                                            </telerik:RadComboBox>                       
                                                     
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <telerik:RadComboBox ID="ddResponsibleDepartment2" Runat="server" DataSourceID="dsResponsibleDepartments"
                                                                DataTextField="DepartmentCode" DataValueField="DepartmentId" EmptyMessage="Select a Department"
                                                                EnableAutomaticLoadOnDemand="True" ItemsPerRequest="20" MarkFirstMatch="True"
                                                                ShowMoreResultsBox="True" Width="95%" AutoPostBack="False" ZIndex="20000"
                                                                CausesValidation="False">
                                                            </telerik:RadComboBox>
                                                </InsertItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridButtonColumn CommandName="Delete" ConfirmText="Are you sure you want to delete this Product Group?" ButtonType="ImageButton" HeaderText="Delete?" ConfirmDialogType="RadWindow" UniqueName="btnDeleteFinal">
                                        <ItemStyle VerticalAlign="Middle" />
                                <HeaderStyle Width="55px" />
                                </telerik:GridButtonColumn>
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid>

 

<asp:SqlDataSource ID="dsResponsibleLocations" runat="server"
                        ConnectionString="<%$ ConnectionStrings:PPMTESTConnectionString %>"
                        SelectCommand="SELECT  [LocationId],[LocationName] FROM [PartCatLocations] ORDER BY [LocationName] ">
                    </asp:SqlDataSource>
                    <asp:SqlDataSource ID="dsResponsibleDepartments" runat="server"
                        ConnectionString="<%$ ConnectionStrings:PPMTESTConnectionString %>"
                        SelectCommand="SELECT  [DepartmentId],[DepartmentCode] FROM PartCatDepartments where LocationId=@locationid ORDER BY [DepartmentCode] ">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="hflocationid" Name="locationid"  
                                PropertyName="Value" />
                        </SelectParameters>
                    </asp:SqlDataSource>

Galina
Top achievements
Rank 1
 answered on 07 Jun 2018
7 answers
109 views
I have a grid which has this column:

<telerik:GridDateTimeColumn UniqueName="date" DataField="date" HeaderText="Date" ItemStyle-Width="120px"></telerik:GridDateTimeColumn> 

I have a FormTemplate with this line:

<telerik:RadDatePicker ID="datenews" runat="server" SelectedDate='<%# Bind("date") %>'

When I edit a record, this works fine.

When I go to insert a new record I get this:
System.InvalidCastException: Specified cast is not valid 

On the RadDatePicker line above.

Help?

Second question:

I tried to avoid creating the FormTemplate in the first place and use the automatically generated edit / insert form. I could not locate how to manipulate (change width, height, textmode) the text boxes automatically created.







Marin Bratanov
Telerik team
 answered on 07 Jun 2018
0 answers
189 views

Hi, would like to check if it is possible to generate a QR code with a logo in the middle?

 

sample in attached file

Benjamin
Top achievements
Rank 1
 asked on 07 Jun 2018
10 answers
325 views
Is it possible to limit the number of tokens inputted into an autocomplete box via some sort of property or setting?

Thanks!
David
Top achievements
Rank 1
Veteran
Iron
 answered on 06 Jun 2018
7 answers
223 views
I have ExplorerMode="Thumbnails" on my RadFileExplorer.How to set the Thumbnails bigger?
Vessy
Telerik team
 answered on 06 Jun 2018
1 answer
420 views

We need to update the value of the Async Upload Configuration Encryption Key for security reasons in our organization. How do we get the new encryption key value to put in our web.config file. 

Thanks

Marin Bratanov
Telerik team
 answered on 06 Jun 2018
8 answers
181 views
Since upgrading to 2012.1.411.40 I have problem with grids that have multiple group by expressions that have a Header String which aggregates sub totals.

When the grid displays the First Header Grouping of every group level in the Grid does not display correctly. Instead of building up a dynamic string header it instead displays a non dynamic header such as 'Total Charged: {0:c2}'. Subsequent sub-grouping though work.

Here is an example of the type of Group By Expressions used;

<GroupByExpressions>
                        <telerik:GridGroupByExpression>
                            <SelectFields>
                                <telerik:GridGroupByField HeaderValueSeparator=": " FieldAlias="Client" FieldName="ClientName" />
                                <telerik:GridGroupByField HeaderValueSeparator=": " HeaderText="Hrs Spent" FieldAlias="HrsSpent"
                                    FieldName="TimeSpent" FormatString="{0:N1}" Aggregate="Sum" />
                                <telerik:GridGroupByField HeaderValueSeparator=": " HeaderText="Total Charged" FieldAlias="TotalCharged"
                                    FieldName="WorksheetAmount" FormatString="{0:c2}" Aggregate="Sum" />
                                <telerik:GridGroupByField HeaderValueSeparator=" " HeaderText=" " FieldAlias="ClientID"
                                    FieldName="ClientID" FormatString=" " />
                            </SelectFields>
                            <GroupByFields>
                                <telerik:GridGroupByField FieldName="ClientName" SortOrder="Ascending" />
                            </GroupByFields>
                        </telerik:GridGroupByExpression>
                        <telerik:GridGroupByExpression>
                            <SelectFields>
                                <telerik:GridGroupByField HeaderValueSeparator=": " FieldAlias="Project" FieldName="ProjectTitle" />
                                <telerik:GridGroupByField HeaderValueSeparator=": " HeaderText="Hrs Spent" FieldAlias="HrsSpent"
                                    FieldName="TimeSpent" FormatString="{0:N1}" Aggregate="Sum" />
                                <telerik:GridGroupByField HeaderValueSeparator=": " HeaderText="Total Charged" FieldAlias="TotalCharged"
                                    FieldName="WorksheetAmount" FormatString="{0:c2}" Aggregate="Sum" />
                                <telerik:GridGroupByField HeaderValueSeparator=" " HeaderText=" " FieldAlias="ProjectID"
                                    FieldName="ProjectID" FormatString=" " />
                            </SelectFields>
                            <GroupByFields>
                                <telerik:GridGroupByField FieldName="ProjectTitle" SortOrder="Ascending" />
                            </GroupByFields>
                        </telerik:GridGroupByExpression>
                        <telerik:GridGroupByExpression>
                            <SelectFields>
                                <telerik:GridGroupByField HeaderValueSeparator=": " FieldAlias="Office" FieldName="OfficeName" />
                                <telerik:GridGroupByField HeaderValueSeparator=": " HeaderText="Hrs Spent" FieldAlias="HrsSpent"
                                    FieldName="TimeSpent" FormatString="{0:N1}" Aggregate="Sum" />
                                <telerik:GridGroupByField HeaderValueSeparator=": " HeaderText="Total Charged" FieldAlias="TotalCharged"
                                    FieldName="WorksheetAmount" FormatString="{0:c2}" Aggregate="Sum" />
                                <telerik:GridGroupByField HeaderValueSeparator=" " HeaderText=" " FieldAlias="OfficeID"
                                    FieldName="OfficeID" FormatString=" " />
                            </SelectFields>
                            <GroupByFields>
                                <telerik:GridGroupByField FieldName="OfficeName" SortOrder="Ascending" />
                            </GroupByFields>
                        </telerik:GridGroupByExpression>
                        <telerik:GridGroupByExpression>
                            <SelectFields>
                                <telerik:GridGroupByField HeaderValueSeparator=": " FieldAlias="Job" FieldName="JobTitle" />
                                <telerik:GridGroupByField HeaderValueSeparator=": " HeaderText="Hrs Spent" FieldAlias="HrsSpent"
                                    FieldName="TimeSpent" FormatString="{0:N1}" Aggregate="Sum" />
                                <telerik:GridGroupByField HeaderValueSeparator=": " HeaderText="Total Charged" FieldAlias="TotalCharged"
                                    FieldName="WorksheetAmount" FormatString="{0:c2}" Aggregate="Sum" />
                                <telerik:GridGroupByField HeaderValueSeparator=" " HeaderText=" " FieldAlias="ProjectID"
                                    FieldName="ProjectID" FormatString=" " />
                                <telerik:GridGroupByField HeaderValueSeparator=" " HeaderText=" " FieldAlias="JobID"
                                    FieldName="JobID" FormatString=" " />
                            </SelectFields>
                            <GroupByFields>
                                <telerik:GridGroupByField FieldName="JobTitle" SortOrder="Ascending" />
                            </GroupByFields>
                        </telerik:GridGroupByExpression>
                    </GroupByExpressions>

See screenshot of issue attached.

This exact same code worked perfectly in 2011 Q3 Dll's.
Has anything changed between versions?

Cheers,

Damien.




Vessy
Telerik team
 answered on 06 Jun 2018
6 answers
645 views
When a grid view has template columns with images and hyperlinks. The PDF export does not render these columns.
Is there a fix or work around for this bug ?


fsr
Top achievements
Rank 1
 answered on 06 Jun 2018
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?