Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
63 views
And my endless problems from server created controls continue.

I have users that are in different groups and each group has different user information. I am creating a page to manage users in a group using a Telerik RadGrid. Because of the unknown nature of the grid columns I am creating the grid on completely on the server.  You cannot have a grid defined in the aspx page and add columns in the server aspx.cs code, all kinds of things break like sorting, filters and extra text added.  The grid works fine.  

A feature I need is to output excel files with the grid's data. The problem, how do I reference the grid in server calls backs. If you look at Grid Export To Excel there is a button callback that changes grid values on the server and initiates the excel export on the grid control in ImageButton_Click.  In my case RadGrid1 is created in the server in the Page_Init and added to an asp:PlaceHolder. 

Is there any way to reference a server added control back in the server aspx.cs code.  Putting the control id will not compile.

I am going to want deal with Row Selected values which will also need server intervention dealing with the selected rows.

Thanks,
George
George
Top achievements
Rank 2
 answered on 16 Mar 2015
3 answers
253 views
Dear Sir,

There is user requirement to using combobox with checkbox for mulit-selection of code.  If "top 10" was removed the combobox didn't show any record. After check that, there are almost 7xxx records, do you mean that the combobox with checkbox with max. limitation of the record? If yes, what is the max. number of the records?
There is the code:
.aspx
 <telerik:RadComboBox runat="server" ID="cboSupplier" 
      CheckBoxes="true" EnableCheckAllItemsCheckBox="true"
      AutoPostBack="false" CssClass="comboBoxStyle"
      DataTextField="SUPCD"
      
     EnableLoadOnDemand="True"  Height="200px" Width="95%">
</telerik:RadComboBox> 

.vb
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 If Not Me.IsPostBack Then
 LoadSupplier()
end if
End Sub
  Protected Sub LoadSupplier()
        cboSupplier.Items.Clear()
        Dim dbConn As New SqlConnection(WebConfigurationManager.ConnectionStrings("PDBConnectionString").ConnectionString)
        Dim adapter As New SqlDataAdapter("SELECT top 10 RTRIM(MSUP_SUPCD) MSUP_SUPCD,RTRIM(MSUP_SUPNM) MSUP_SUPNM FROM MSUP_TBL Group by RTRIM(MSUP_SUPCD) ,RTRIM(MSUP_SUPNM) ORDER By MSUP_SUPCD ", dbConn)
        Dim dt As New DataTable()
        adapter.Fill(dt)
        cboSupplier.DataTextField = "MSUP_SUPCD"
        cboSupplier.DataValueField = "MSUP_SUPCD"
        cboSupplier.DataSource = dt
        cboSupplier.DataBind()
        ' Insert the first item.
        cboSupplier.Items.Insert(0, New RadComboBoxItem("", ""))
    End Sub








Nencho
Telerik team
 answered on 16 Mar 2015
1 answer
75 views
When using LoadSettings() with an OpenAccessLinqDataSource be careful to specify DataSourceControlID="MyOpenAccessLinqDataSource" and not FilterContainerID="MyRadGrid".

If you're not using LoadSettings(), the RadFilter works OK with both strategies but if you're using a OpenAccessLinqDataSource and doing LoadSettings() then you must make the RadFilter element's DataSourceControlID attribute to refer to your datasource.

The demo for the Loading and saving of filter expressions uses a SQL data source and makes the filter point to the grid:

<telerik:RadFilter runat="server" ID="RadFilter1" FilterContainerID="RadGrid1"></telerik:RadFilter>

If instead of a SQL data source, you use a OpenAccessLinqDataSource, strange things will happen to the queries. For some reason, the query will be run a first time and then a second time but with the filter appearing *double* (where mycolumn = 1 and mycolumn = 1).

It won't fail but naturally, you don't want to execute your queries twice.

Also, visible during debug:
- in the output, a SqlSyntaxError error is thrown
- the _Selecting() event handler of the data source is called twice; the first time the data source's where property shows the correct where clause (as defined by the RadFilter that was set using LoadSettings() ); the second time with the radfilter's conditions repeated.

I found that declaring RadFilter as seen in the demo for integration with the data source works :

<telerik:RadFilter runat="server" ID="RadFilter1" 
  DataSourceControlID="EntityDataSourceCustomers" 
 OnApplyExpressions="RadFilter1_ApplyExpressions">
</telerik:RadFilter>

NOTE: I am not sure if this behaviour is specific to OpenAccessLinqDataSource or if it also happens with the SQL source. I didn't check.
Vasil
Telerik team
 answered on 16 Mar 2015
16 answers
413 views
Hello,

I have a grid whose items I am always keeping in edit mode. But I've noticed that certain operations (such as column sorting, for example), causes the edit items to revert back to browse mode. To avoid this, I handle the grid commands explicitly, and set the grid back to edit mode once the command has executed.

Here is my declaration of the grid:
<telerik:RadGrid ID="dtgBuildingSizes" runat="server" AllowPaging="true" AllowSorting="true" AllowFilteringByColumn="true" ShowFooter="true"
    AutoGenerateColumns="false" EnableHeaderContextMenu="true" EnableHeaderContextFilterMenu="true" PageSize="5"
    AllowMultiRowEdit="true" Width="100%" EnableLinqExpressions="false"
    OnNeedDataSource="dtgBuildingSizes_NeedDataSource" OnItemDataBound="dtgBuildingSizes_ItemDataBound"
    OnPreRender="dtgBuildingSizes_PreRender" OnItemCommand="dtgBuildingSizes_ItemCommand">
    <MasterTableView DataKeyNames="Id" EditMode="InPlace" IsFilterItemExpanded="false">
        <Columns>
            <telerik:GridBoundColumn UniqueName="SizeTypeDescr" DataField="SizeTypeDescr" HeaderText="<%$ Resources: SizeType %>" ReadOnly="true" />
            <telerik:GridNumericColumn UniqueName="Size" DataField="Size" DataType="System.Decimal" ItemStyle-HorizontalAlign="Right"
                HeaderStyle-HorizontalAlign="Right" HeaderText="<%$ Resources:RpaControlCaptions, lblSize %>" />
            <telerik:GridButtonColumn UniqueName="Delete" CommandName="Delete" ButtonCssClass="rgDel" ButtonType="LinkButton"
                    ItemStyle-HorizontalAlign="Right" ShowInEditForm="true"
                    ConfirmText="<%$ Resources: AreYouSureYouWantToDeleteThisSize %>" />
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

And here is the relevant C# code:
protected void dtgBuildingSizes_PreRender(object sender, EventArgs e)
{
    //initially set appropriate size grid rows to edit mode
    if (!IsPostBack)
        dtgBuildingSizes.SetSizesGridToEditMode();
}
 
protected void dtgBuildingSizes_NeedDataSource(object sender, TelerikUI.GridNeedDataSourceEventArgs e)
{
    var dataSource = ((BuildingEntity)CurrentBusinessEntity).Sizes;
    dtgBuildingSizes.DataSource = dataSource;
    dtgBuildingSizes.VirtualItemCount = dataSource.Count;
}
 
protected void dtgBuildingSizes_ItemDataBound(object sender, TelerikUI.GridItemEventArgs e)
{
    if (e.Item is TelerikUI.GridDataItem)
    {
        TelerikUI.GridDataItem dataItem = (TelerikUI.GridDataItem)e.Item;
 
        //show/hide delete button based on availability for the size type
        BuildingSizeEntity entity = (BuildingSizeEntity)dataItem.DataItem;
        dataItem["Delete"].Controls[0].Visible = entity.IsDeletable;
    }
}
 
protected void dtgBuildingSizes_ItemCommand(object sender, TelerikUI.GridCommandEventArgs e)
{
    switch (e.CommandName)
    {
        case RadGrid.DeleteCommandName:
            if (e.Item is TelerikUI.GridDataItem)
            {
                //remove the selected entity from the collection
                TelerikUI.GridDataItem dataItem = (TelerikUI.GridDataItem)e.Item;
                BuildingSizeEntity deletedEntity = GetSizeEntityForGridItem(dataItem);
                ((BuildingEntity)CurrentBusinessEntity).Sizes.Remove(deletedEntity);
            }
            break;
        default:
            if (ControlsUtil.IsRebindNeededForRadGridCommand(e.CommandName))
            {
                //save previous edits before rebind
                PostAllSizeData();
 
                //execute command and place grid back into edit mode
                e.ExecuteCommand(sender);
                dtgBuildingSizes.SetSizesGridToEditMode();
 
                e.Canceled = true//no further processing required
            }
            break;
    }
}
 
public static bool IsRebindNeededForRadGridCommand(string commandName)
{
    switch (commandName)
    {
        // Editing
        case RadGrid.CancelAllCommandName:
        case RadGrid.CancelCommandName:
        case RadGrid.DeleteCommandName:
        case RadGrid.DeleteSelectedCommandName:
        case RadGrid.EditAllCommandName:
        case RadGrid.EditCommandName:
        case RadGrid.EditSelectedCommandName:
        case RadGrid.InitInsertCommandName:
        case RadGrid.PerformInsertCommandName:
        case RadGrid.UpdateCommandName:
        case RadGrid.UpdateEditedCommandName:
 
        // Filtering
        case RadGrid.ClearFilterCommandName:
        case RadGrid.FilterCommandName:
        case RadGrid.HeaderContextMenuFilterCommandName:
 
        // Paging
        case "ChangePageSize":
        case RadGrid.FirstPageCommandArgument:
        case RadGrid.LastPageCommandArgument:
        case RadGrid.NextPageCommandArgument:
        case RadGrid.PageCommandName:
        case RadGrid.PrevPageCommandArgument:
 
        // Sorting
        case RadGrid.ClearSortCommandName:
        case RadGrid.SortCommandName:
 
        // Misc.
        case RadGrid.ExpandCollapseCommandName:
        case RadGrid.RebindGridCommandName:
            return true;
        default:
            return false;   //all others do not implicitly call rebind
    }
}
 
public static void SetSizesGridToEditMode(this RadGrid grid)
{
    if (grid != null)
    {
        SizeEntity size;
        foreach (GridDataItem dataItem in grid.Items)
        {
            size = dataItem.DataItem as SizeEntity;
            if (size != null)
                dataItem.Edit = !size.IsReadOnly;   //only set editable items to edit mode
        }
 
        grid.Rebind();
    }
}

This works perfectly for all grid commands with the exception of the command to change the page size. When I call ExecuteCommand( ) for the GridPageSizeChangedEventArgs object (e) passed in, it throws a NullReferenceException, causing the action to fail.

How can I execute the page size event and keep my grid items always in edit mode? I realize that I can workaround this by removing the "default" case from the ItemCommand event handler and by removing the "if (!IsPostBack)" check from the grid's PreRender event handler, but I don't want to rebind the grid twice (first for the initial items, then again for setting each item to edit mode) every time the grid has to be rendered. I've noticed that this approach significantly slows down performance, especially when there are many grids being rebound several times each for each postback.

Is there a way I can get around this exception? Or alternatively, is there another way to ensure that the grid items are always in edit mode that doesn't require binding the grid twice?

Thanks!
Geoff
Pavlina
Telerik team
 answered on 16 Mar 2015
1 answer
177 views
Hello,

When changing to Lightweight mode, the icons for edit and delete (Silk skin) disappear.
They become standard blank buttons. 
This is in Q3 and Q1. (And earlier 2014)
Browser: Chrome & IE

Attached you see my results (image)

Code:
<telerik:TreeListButtonColumn UniqueName="DeleteColumn" ButtonType="ImageButton" CommandName="Delete" ToolTip="Delete this row" MinWidth="30px" MaxWidth="30px" HeaderStyle-Width="30px" Resizable="False" Reorderable="False" />
 
<telerik:TreeListButtonColumn UniqueName="EditColumn" ButtonType="ImageButton" CommandName="Edit" ToolTip="Edit this row (Double Click)" MinWidth="40px" MaxWidth="40px" HeaderStyle-Width="40px" Resizable="False" Reorderable="False" />
^ Above is tested in a new project 

How do I keep the same behavior in Lightweight mode?

Kind Regards,

Erik
Venelin
Telerik team
 answered on 16 Mar 2015
1 answer
93 views
i have telerik radcombobox , i have upgraded the telerik version to 2014.3.1209.35, but then my ui of combobox is completely unbalanced.
Magdalena
Telerik team
 answered on 16 Mar 2015
3 answers
225 views
I have a radcombobox with checkboxes. It has a javascript that has to enable another textbox depending on the value of selected item.
The javascript is called when the checkbox is selected but it does not find selected items first time.
when we click second time it finds only the first one. And so on.

I have a code snippet to reproduce this issue. This used to work before I installed updates.
2015.1.225.40 installed.

I am using C# 2012
.net vesrion 4.5

In this code snippet, I am updating  the value of label. The Label shows the values of selected items '-' seperated.
So first time if I select 44 (value 4)  .... The Label shows nothing
then if I select 11(value 1)  .... The Label shows -4
then if I select 77(value 7)  .... The Label shows   -1- 4 
and so on.

I hope I have explained my scenario good enough. Please let me know if you need any more clarification.
------------- Javascript -----------
    function OnNCAAChange(sender, args) {
        var NCAA;
        var Label1;

        NCAA = $telerik.$("[id$='UINCAA']");
        Label1 = $telerik.$("[id$='Label1']");
        Label1[0].textContent = "";
        for (var i = 0; i < sender.get_items().get_count() ; i++) {
            var item = sender.get_items().getItem(i);
            var checkbox = item.get_checkBoxElement();
            if (checkbox.checked) {
                Label1[0].textContent = Label1[0].textContent + ' - ' +  item.get_value();
            }
        }
    }

--------- Controls -----------------
 <telerik:RadComboBox runat="server" ID="UINCAA" Width="60%" CheckBoxes="true" EnableCheckAllItemsCheckBox="false"
                                    OnClientItemChecking="OnNCAAChange" Style="z-index: 8100" MaxHeight="240" ItemsPerRequest="10">
                                </telerik:RadComboBox>
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

--------Codebehind -------------
   protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //List<RadComboBoxItem> rcblist;
            //rcblist = GlobalCodes.GetRCBListBySTSVer(GlobalCodes.Database.STS_Congenital, "3.22", "NCAA", false);

            UINCAA.Items.Clear();
            string t = "1";
            for (int i = 1; i < 10; i++ )
            {
                //RadComboBoxItem hc;
                RadComboBoxItem rc = new RadComboBoxItem();
                rc.Text = t + i.ToString();
                rc.Value = i.ToString();
                UINCAA.Items.Add(rc);

            }
        }

    }

   


Ivan Danchev
Telerik team
 answered on 16 Mar 2015
2 answers
110 views
Having trouble with the PDF export functionlaity. I created a page and copied the sample test from the site

http://www.telerik.com/help/aspnet-ajax/clientexportmanager-getting-started.html

When I click the button I get:

Error: Object doesn't support property or method 'exportPdf'

I can export an image, but not a pdf.

What am I missing? Thank.

Using...  2015.1.204.40
Mbott
Top achievements
Rank 1
 answered on 16 Mar 2015
1 answer
45 views
Hi,

I am using Radeditor in .net.
 I want to add comment to trackchanges content but add comment button not responding

can i add comment to trackchanges content?

Thanks & Regards,
M.Raju
Ianko
Telerik team
 answered on 16 Mar 2015
5 answers
145 views
Hi,
CommonTooltipsAppearance.Shared = true not work (java script error), same code with previous version work fine.

Thanks
Gianmarco
Danail Vasilev
Telerik team
 answered on 16 Mar 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?