Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
33 views

Greetings,

I'm currently trying to revamp one of my pages from server side binding to a web service binding and encountered a hickup.

The page is as follows (see picture attached):

The Outside is a RadSplitter.
On the left side of the RadSplitter is an update panel, where inside is the RadTreeView.
On the right side, also inside an update panel, is a RadGrid.

The RadTreeView gets a basic set of nodes ("stations") on creation, but everything after that is loaded on demand by webservice. If a "station" is expaned, and the webservice is triggered and supplies nodes to the radgrid. This works correctly.
If I click on a "station", a client side event is triggered, which expands the node (therefore triggering the webservice and supplying nodes) and also calling the RadGrid to rebind (by client side). The Rebind triggers the OnNeedDataSource event of the RadGrid, where it loads its data server side. 

The problem is with the click & expand, as the nodes are then only briefly visible in the RadTreeView and immediately removed again.

Is this a know problem? What can I do? I need the nodes in the tree but also the data in the RadGrid.
I made a video of the error, but it seems I cannot upload the video here. I also created a very basic test project.

I'm using Telerik 2023.1.117.45.

Thank you in advance!

Vasko
Telerik team
 answered on 12 Mar 2024
0 answers
20 views

Hi,

I have following grind in Batch Edit mode, is it possible to change cboKAC DataSourceID in code behind or JS? In other words - how to access controls on EditTemplate in Batch Edit mode?

Thanks,

Alex

<telerik:RadGrid ID="grdLinks" runat="server" AllowSorting="true" AllowPaging="false" Width="300px" Height="120px">
    <ClientSettings><Scrolling AllowScroll="true" /><Selecting AllowRowSelect="true" /></ClientSettings>
    <MasterTableView CommandItemDisplay="Top" AllowFilteringByColumn="false" AllowSorting="false" EditMode="Batch" EnableViewState="True" Width="100%" AutoGenerateColumns="false"
        CommandItemSettings-ShowCancelChangesButton="false" CommandItemSettings-ShowSaveChangesButton="false" CommandItemSettings-ShowRefreshButton="false"
        NoMasterRecordsText="" ShowHeader="false">
        <EditFormSettings EditFormType="AutoGenerated" EditColumn-ButtonType="PushButton" />
        <Columns>
            <telerik:GridTemplateColumn HeaderText="Task" HeaderStyle-Width="150px" DataField="lfaNum" UniqueName="lfaNum">
                <ItemTemplate>
                    <a target='_blank'  href='XXX.aspx?Num=<%# Eval("lfaNum")  %>'><%# Eval("lfaNum")  %></a>
                </ItemTemplate>
                <EditItemTemplate>
                    <telerik:RadComboBox ID="cboKAC" DataTextField="lfaNum" DataValueField="lfaID" DataSourceID="dsLFA"
                        DropDownAutoWidth="Enabled" Filter="Contains" runat="server"
                        EnableAutomaticLoadOnDemand="True" ItemsPerRequest="20" ShowMoreResultsBox="true" EnableVirtualScrolling="true" CausesValidation="false">
                    </telerik:RadComboBox>
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridButtonColumn CommandName="Delete" Text="Delete" ButtonType="ImageButton" UniqueName="DeleteButton" HeaderStyle-Width="30px" />
        </Columns>
    </MasterTableView>        
</telerik:RadGrid>

 

Alex Dybenko
Top achievements
Rank 2
 asked on 04 Mar 2024
0 answers
48 views

Hi All,

We are using the below code for xlsx format export using the Telerik.Web.UI.dll.

  "gridControl.ExportSettings.Excel.Format = GridExcelExportFormat.Xlsx;"

Is that enough to work in production? and advice if we purchase the DevCraft Ultimate, will it be working fine?

Dev
Top achievements
Rank 1
 asked on 01 Mar 2024
0 answers
29 views

I need to get a reference to a telerik control contained in the commanditemtemplate of a radgrid using javascript.

Given the following:


<CommandItemTemplate>
<asp:Table>
<asp:TableRow>
<asp:TableCell>
<telerik:RadComboBox runat=server ID="RadComboBox_CommandItem">


How would I get the reference to the ComboBox?

 

I've tried window.$find, $telerik.findControl and $telerik.findElement, but I keep getting a " CS0103: The name 'RadComboBox_CommandItem' does not exist in the current context"

ToltingColtAcres
Top achievements
Rank 2
Veteran
Iron
 asked on 27 Feb 2024
0 answers
32 views

I have a fairly standard data grid


<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" BackgroundPosition="Center" Skin="Default">
</telerik:RadAjaxLoadingPanel>
<telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel" LoadingPanelID="RadAjaxLoadingPanel1">
	<asp:UpdatePanel ID="UpdatePanel2" runat="server">    
		<ContentTemplate>
		<telerik:RadGrid RenderMode="Lightweight" ID="RadGrid1" runat="server" EnableViewState="true" AutoGenerateColumns="false" Height="100%"
			AllowSorting="true" GroupingEnabled="false" EnableLinqExpressions="false" AllowCustomSorting="true"
			EnableHeaderContextMenu="false" OnNeedDataSource="RadGrid1_NeedDataSource" AllowMultiRowSelection="true" AllowPaging="false">
			<MasterTableView TableLayout="Fixed" ClientDataKeyNames="ID" AllowCustomPaging="true" AllowPaging="True" PageSize="50"/>
			<ClientSettings EnableRowHoverStyle="true">
				<Virtualization EnableVirtualization="true" InitiallyCachedItemsCount="50"
					LoadingPanelID="RadAjaxLoadingPanel1" ItemsPerView="50" RetrievedItemsPerRequest="50"/>
				<Scrolling AllowScroll="true" UseStaticHeaders="true"/>
				<Resizing AllowColumnResize="true" ResizeGridOnColumnResize="true"/>
				<Selecting AllowRowSelect="True" UseClientSelectColumnOnly="true" CellSelectionMode="None" />
				 <ClientEvents OnKeyPress="KeyPress" />
			</ClientSettings>
			<PagerStyle Mode="NextPrevAndNumeric" PageSizeControlType="RadDropDownList" CssClass="TelerikPager"/>
		</telerik:RadGrid>
		</ContentTemplate>
	</asp:UpdatePanel>
</telerik:RadAjaxPanel>

I have 1007 items to show. Everything work fine, until I get to the last page, be it with scroll, clicking next pages, or jump to end button. For the last page (page 21, so index 20) the Grid in RadGrid1_NeedDataSource on it's MasterTableView.CurrentPageIndex has 19. So I return the wrong portion of the data.

Is something set up wrong or is there some other issue?

Up until that point everything is great, for page 19, index is 18, for 20 index is 19, and then for 21 it's again 19.

There is no rebind happening in the code and there is nothing really interesting happening on the server side code.

 

Valent
Top achievements
Rank 1
 asked on 22 Feb 2024
1 answer
25 views

Hi,

I would like to use a version of this code

// Event fires upon a cell is intering into edit mode
function OnBatchEditOpening(sender, args) {

    // get the unique name of the column
    var columnName = args.get_columnUniqueName();

    // get the currently edited row's ID
    var rowId = parseInt(args.get_row().id.split("__")[1]);

    // Setup a condition for the row ID
    if (rowId % 3 == 0) { // If condition 1 is met

        // if this row and the Freight column
        if (columnName == "Freight") {
            // cancel the Editing event
            args.set_cancel(true);
        }
    } 
}

to get the value of the cell.  If the cell is empty (null or a space), then I don't want the cell to be editable.  In this Javascript, how do I get the actual value of the cell?

This code is getting me close

var cell = args.get_cell();
alert(cell.childNodes[0].innerHTML)

but it is showing the whole span, like this:
<span id="ctl00_MainContent_mygrid_ctl00_ctl10_mylabel">this is the value I want to access</span>

Thanks!

Nancy
Top achievements
Rank 1
Iron
 answered on 22 Feb 2024
1 answer
31 views

Hi,

My situation: I have a Radgrid with TooltipManager setup which works fine.

Now I have to place another RadGrid in the Tooltip which has an update button per row.
How would one configure so, that the Tooltip's RadGrid is updated in the Tooltip.
Please see attached screenshot...

Thanks for any pointers.

Marc

Vasko
Telerik team
 answered on 20 Feb 2024
1 answer
29 views

Hi,

Could you, please help me find code examples for how to format filter dropdown items of decimal and datetime fields(columns) in telerik:RadGrid.
We need a comma separator for decimal fields.  Also, there is a chance of negative values, so in that case, we need to show its absolute value(within parentheses).
In the case of datetime fields, we need only the date without the time part (date format will be different for different agencies).

We changed the format of Invoice Date column in  ItemDataBound event as below.

dataItem["Date"].Text = rowItem.Date.ToString(AgencyDateFormat);

But it only changed the grid column values, not the filter dropdown.(image of mentioned issue is given below)

We changed the format of Amount column in  ItemDataBound event as below.

dataItem["Amt"].Text = string.Format("{0:0,0.00;(0.00)}", rowItem.Amt);

But it only changed the grid column values, not the filter dropdown.(image of mentioned issue is given below)

 

What we need is for the values shown in the filter will be in the same format of the corresponding column.

I solved this issue by using following code:

private void RadGrid_GridFilterCheckListItemsRequested(object sender, GridFilterCheckListItemsRequestedEventArgs e)
        {
            string filterKey = e.Column.UniqueName;
            List<string> listOfItems = GetList(filterKey);

            foreach (var item in listOfItems)
            {
                if (e.Column.DataType == typeof(DateTime))
                {
                    DateTime datimeObj;
                    if (DateTime.TryParse(item, out datimeObj))
                    {
                        e.ListBox.Items.Add(new RadListBoxItem
                        {
                            Text = datimeObj.ToString(AgencyDateFormat),
                            Value = item
                        });
                        e.ListBox.DataTextFormatString = AgencyDateFormat;
                    }
                }
                else if (e.Column.DataType == typeof(decimal))
                {
                    decimal moneyObj;
                    if (decimal.TryParse(item, out moneyObj))
                    {
                        e.ListBox.Items.Add(new RadListBoxItem
                        {
                            Text = string.Format("{0:0,0.00;(0.00)}", moneyObj),
                            Value = item
                        });
                    }
                }
                else
                {
                    e.ListBox.DataSource = listOfItems;
                }
            }
            e.ListBox.DataBind();
        }

There is one more issue I'm facing. If the column contains a null or empty string, then I need to show them as "(Empty)" in the filter drop-down. How to do this?

We will appreciate your help.

Thanks

            
Vasko
Telerik team
 answered on 19 Feb 2024
0 answers
25 views
I have a Windows 11 machine with a Logitech mouse.  When I have the mouse pointer within a RadGrid, I can turn the mouse wheel to scroll the grid contents vertically and I can hold down the SHIFT key and turn the mouse wheel to scroll the grid contents horizontally.  Alternatively, I can hold the mouse wheel down and move the mouse to scroll the contents vertically or horizontally.  As soon as I freeze columns in the RadGrid, I lose the ability to scroll horizontally with the mouse wheel.

The issue can be demonstrated on the Telerik Web UI Grid Scrolling Demo page by enabling/disabling frozen columns.

Is this something that can be looked into?

Regards,
Dave
David
Top achievements
Rank 1
 asked on 13 Feb 2024
2 answers
1.6K+ views
We're getting this error in the prerender event of the page with a grid:

Error message: Object reference not set to an instance of an object.

Stack trace:    at Telerik.Web.UI.RadComboBox.OnInit(EventArgs e)

   at System.Web.UI.Control.InitRecursive(Control namingContainer)

   at System.Web.UI.Control.AddedControl(Control control, Int32 index)

   at Telerik.Web.UI.GridPagerItem.InitializePagerItem(GridColumn[] columns)

   at Telerik.Web.UI.GridPagerItem.SetupItem(Boolean dataBind, Object dataItem, GridColumn[] columns, ControlCollection rows)

   at Telerik.Web.UI.GridTableView.CreateTopPagerItem(Boolean useDataSource, GridColumn[] copiedColumnSet, Boolean isPagingEnabled, GridTHead thead)

   at Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource)

   at Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource)

   at System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls()

   at System.Web.UI.Control.EnsureChildControls()

   at Telerik.Web.UI.GridTableView.get_Items()

   at Telerik.Web.UI.GridTableView.GetSelectedItems()

   at XXX.StudentSearch_PreRender(Object sender, EventArgs e) in C:\XXX\StudentSearch.aspx.vb:line 140

   at System.EventHandler.Invoke(Object sender, EventArgs e)

   at System.Web.UI.Control.PreRenderRecursiveInternal()

   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


Private Sub StudentSearch_PreRender(sender As Object, e As System.EventArgs) Handles Me.PreRender
        If grd.MasterTableView.GetSelectedItems.Count > 0 And grd.Visible Then
            tab.Visible = True
            mp.Visible = True
        Else
            tab.Visible = False
            mp.Visible = False
        End If
    End Sub
The error is occurring in the GetSelectedItems call. I had originally used the SelectedItems, but was getting an error with that occasionally, so I switched to GetSelectedItems. The error doesn't always happen, so it's not something I can easily reproduce.

Below is the definite for the RadGrid:
<telerik:RadGrid ID="grd" runat="server" AutoGenerateColumns="False" CellSpacing="0"
                    GridLines="None" AllowPaging="True" PageSize="20" Width="600px">
                    <ClientSettings>
                        <Selecting AllowRowSelect="False" />
                    </ClientSettings>
                    <MasterTableView HierarchyDefaultExpanded="false" HierarchyLoadMode="ServerOnDemand"
                        DataKeyNames="StudentUID">
                        <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                            <HeaderStyle Width="20px"></HeaderStyle>
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                            <HeaderStyle Width="20px"></HeaderStyle>
                        </ExpandCollapseColumn>
                        <Columns>
                            <telerik:GridButtonColumn CommandName="Select" FilterControlAltText="Filter column column"
                                Text="Open" UniqueName="column" ButtonType="ImageButton" ImageUrl="Images/Open.gif">
                                <ItemStyle Width="20px" />
                            </telerik:GridButtonColumn>
                            <telerik:GridBoundColumn DataField="StudentID" FilterControlAltText="Filter column1 column"
                                HeaderText="Student ID" UniqueName="column1">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="LastName" FilterControlAltText="Filter column2 column"
                                HeaderText="Last Name" UniqueName="column2">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="FirstName" FilterControlAltText="Filter column4 column"
                                HeaderText="First Name" UniqueName="column4">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Middle" FilterControlAltText="Filter column3 column"
                                HeaderText="Middle" UniqueName="column3">
                            </telerik:GridBoundColumn>
                        </Columns>
                        <EditFormSettings>
                            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                            </EditColumn>
                        </EditFormSettings>
                    </MasterTableView>
                    <FilterMenu EnableImageSprites="False">
                    </FilterMenu>
                    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
                    </HeaderContextMenu>
                </telerik:RadGrid>


Attila Antal
Telerik team
 answered on 01 Feb 2024
Narrow your results
Selected tags
Tags
+? more
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?