Telerik Forums
UI for ASP.NET AJAX Forum
9 answers
1.3K+ views
Hello

I have a RadGrid that works well : it shows the rows in the dataSource and I can use the seeded buttons to add rows etc ...

Now I want to some rows programmatically, so I modify the DataSource in the codeBehind then run RadGrid. Rebind() but it does not shows the new datasource rows.

What could be the explanation for this ?

Loko
Arnaud
Top achievements
Rank 1
 answered on 13 Aug 2014
11 answers
1.0K+ views
Hi,

I have a radgrid with 2 columns, the first column has a dropdown and the second column has a textbox. outside the grid there is a Add "Add ROw" which should insert one row to the grid. The newly added row should have  a dropdown(binded with soime data) in 1st and textox in the 2nd column. The dat entered or selected for previous row must be retained.

Please let me know how this can be achevied.
Please reply at the earliest.
Viktor Tachev
Telerik team
 answered on 13 Aug 2014
1 answer
385 views
I've come across an issue with exporting the radgrid to csv and excel files when using the item template. I've poked around a bit on the forums to see what solutions are already present and from what I've gathered I should set the text field of my item template columns before exporting. The problem I am running into is when I try to find the control it keeps returning null (or in this case Object reference not set to an instance of an object).

My Grid Exporting Event:
protected void RadGridInventory_GridExporting(object source, GridExportingArgs e)
        {
            foreach (GridDataItem item in RadGridInventory.MasterTableView.Items)
            {
                item["AccountId"].Text = (item.FindControl("lControl") as HyperLink).Text; //returns null
                item["Status"].Text = (item.FindControl("statusCode") as LiteralControl).Text; //returns null
            }
 
            if (e.ExportType == ExportType.Excel)
            {
                string customText = "<h1 style='text-align:center;'>Inventory Report for " + _applicationUser.Customer.Name + "</h1>";
                customText += "<p style='text-align:center;'><b>Current Date:</b> " + DateTime.Now + "<br />";
 
                if(RadDatePickerStarting.SelectedDate != null && RadDatePickerEnding.SelectedDate != null){
                    customText += "<b>Date Range Covered:</b> " + RadDatePickerStarting.SelectedDate + " - " + RadDatePickerEnding.SelectedDate + "<br />";
                } else {
                    customText += "<b>Date Range Covered:</b> " + RadComboBoxChoices.SelectedItem.Text + "<br />";
                }
 
                customText += "<b>Clients:</b>";
                foreach (var client in ClientSelector1.SelectedClients)
                {
                    customText += " " + client.Name + ",";
                }
 
                customText = customText.TrimEnd(',');
                customText += "</p>";
                e.ExportOutput = e.ExportOutput.Replace("<body>", "<body>" + customText);
            }
        }

The RadGrid:
public void BuildGrid(IList<UserReportColumn> userReportColumns)
        {
            RadGridInventory.FilterMenu.EnableEmbeddedSkins = false;
            RadGridInventory.PreRender += RadGridInventory_PreRender;
            RadGridInventory.EnableLinqExpressions = false;
 
            RadGridInventory.AllowFilteringByColumn = true;
            RadGridInventory.AllowPaging = true;
            RadGridInventory.AllowSorting = true;
            RadGridInventory.GridLines = GridLines.None;
            RadGridInventory.ShowGroupPanel = true;
            RadGridInventory.AutoGenerateColumns = false;
            RadGridInventory.CssClass = "RadGridAccounts";
            RadGridInventory.EnableViewState = false;
            RadGridInventory.Width = Unit.Pixel(1090);
            RadGridInventory.EnableEmbeddedSkins = false;
 
            RadGridInventory.ClientSettings.AllowDragToGroup = true;
            RadGridInventory.ClientSettings.Resizing.AllowColumnResize = true;
            RadGridInventory.ClientSettings.Resizing.AllowRowResize = true;
            RadGridInventory.ClientSettings.Resizing.ResizeGridOnColumnResize = true;
            RadGridInventory.ClientSettings.Resizing.ClipCellContentOnResize = true;
            RadGridInventory.ClientSettings.Resizing.EnableRealTimeResize = false;
            RadGridInventory.ClientSettings.Resizing.ShowRowIndicatorColumn = false;
 
            RadGridInventory.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric;
            RadGridInventory.ExportSettings.HideStructureColumns = true;
            RadGridInventory.ExportSettings.ExportOnlyData = true;
            RadGridInventory.ExportSettings.IgnorePaging = true;
 
            RadGridInventory.MasterTableView.DataKeyNames = new string[] { "AccountId" };
            RadGridInventory.MasterTableView.ClientDataKeyNames = new string[] { "AccountId" };
            RadGridInventory.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top;
            RadGridInventory.MasterTableView.CommandItemSettings.ShowExportToExcelButton = true;
            RadGridInventory.MasterTableView.CommandItemSettings.ShowExportToCsvButton = true;
            RadGridInventory.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = false;
            RadGridInventory.GridExporting += new OnGridExportingEventHandler(RadGridInventory_GridExporting);
 
            RadGridInventory.MasterTableView.Width = Unit.Percentage(100);
 
            var accountColumn = userReportColumns.FirstOrDefault(x => x.ReportColumn.ColumnName == "AccountId");
            if (accountColumn != null)
            {
                var templateColumn = new GridTemplateColumn();
                RadGridInventory.MasterTableView.Columns.Add(templateColumn);
                templateColumn.ItemTemplate = new AccountColumnTemplate("AccountId");
                templateColumn.DataField = "AccountId";
                templateColumn.SortExpression = "AccountId";
                templateColumn.UniqueName = "AccountId";
                templateColumn.GroupByExpression = "Group By AccountId";
                templateColumn.HeaderText = accountColumn.ColumnHeaderEval;
            }     
             
            foreach (var column in userReportColumns)
            {
                if (column.ReportColumn.ColumnName == "AccountId") continue;
 
                if (column.ReportColumn.ColumnName == "Status") continue;
 
                var boundColumn = new GridBoundColumn();
                RadGridInventory.MasterTableView.Columns.Add(boundColumn);
 
                AccountGridHelpers.SetupBoundColumn(boundColumn, column);
            }
 
            var statusColumn = userReportColumns.FirstOrDefault(x => x.ReportColumn.ColumnName == "Status");
            if (statusColumn != null)
            {
                var statusTemplateColumn = new GridTemplateColumn();
                RadGridInventory.MasterTableView.Columns.Add(statusTemplateColumn);
                statusTemplateColumn.ItemTemplate = new StatusColumnTemplate("Status");
                statusTemplateColumn.DataField = "Status";
                statusTemplateColumn.UniqueName = "Status";
                statusTemplateColumn.AllowFiltering = true;
                statusTemplateColumn.SortExpression = "Status";
                statusTemplateColumn.HeaderText = statusColumn.ColumnHeaderEval;
            
        }


The Account Id Template:
public class AccountColumnTemplate : ITemplate
    {
        protected HyperLink lControl;
        private string _colname;
        public AccountColumnTemplate(string cName)
        {
            _colname = cName;
        }
 
        public void InstantiateIn(System.Web.UI.Control container)
        {
            lControl = new HyperLink {ID = "lControl"};
            lControl.DataBinding += lControl_DataBinding;
            container.Controls.Add(lControl);
        }
 
        public void lControl_DataBinding(object sender, EventArgs e)
        {
            var l = (HyperLink)sender;
            var container = (GridDataItem)l.NamingContainer;
 
            l.Attributes["href"] = "/Secure/AccountDetail.aspx?account=" + ((AccountDtoBase)container.DataItem).AccountId;
 
            l.Text = ((AccountDtoBase)container.DataItem).AccountId;
        }
    }

Any point in the right direction would be greatly appreciated. I'd really like to avoid having to set ExportOnlyData to false (another solution I've seen floating around) since it really ends up just not looking very nice.

Princy
Top achievements
Rank 2
 answered on 13 Aug 2014
1 answer
108 views
i am using telerik rad editor 2013. now when user delete some image form RadEditor-Image Manger,it should show warning confirmation box . by default radEditor provides this thing.
but i want to customize this confirmation dialog.
i want to show following text.
"Are you sure you want to delete this image...?  This action can not be undone....." 

How to confirm box with this text when user try to delete image
Shinu
Top achievements
Rank 2
 answered on 13 Aug 2014
1 answer
146 views
Hi,

I hit Del key into a gridBoundColumn or a gridNumeriColumn in EDIT mode and radgrid fired Delete command...

How to avoid this command? 

If i hit del Key into a description field i don't want delete record.

AllowAutomaticDeletes=False same result.

I don't want to disabled keyboardShortcuts.

If i use a templateColumn with radTextBox to replace gridBoundColumn no delete command fired.

It's a bug?

Thank you.





Princy
Top achievements
Rank 2
 answered on 13 Aug 2014
3 answers
158 views
This demo shows ability to use mouse to drag over rows / and columns and select a block as in excel:

http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/selecting/cell-selection/defaultcs.aspx

However, shift / arrow keys don't to the same thing. They select individual cells as you move.

Is it possible to use shift / arrow keys to select a block of cells like in excel?

thanks
Princy
Top achievements
Rank 2
 answered on 13 Aug 2014
1 answer
153 views
Hi 

Is it possible to format the RadNumericTextBox onkeypress with two decimal places?

This text box requires users to enter amounts.

Grant

  
Shinu
Top achievements
Rank 2
 answered on 13 Aug 2014
2 answers
683 views
When grid is in edit mode, I have a need to find controls on client side. My table is rather simple. I have a quantity column and a unit price column, a change in value on either column would update the subtotal column. On either change, I need to get both current control's value (which is easy to retrieve) and the next column control's value, which I have no idea how to retrieve on client side. Can anyone point me to the right direction?

They are all placed under EditItemTemplate.

Thanks
Jonathan
Top achievements
Rank 2
 answered on 13 Aug 2014
1 answer
76 views
After implementing this

http://www.telerik.com/support/code-library/drag-and-drop-between-radgrid-and-radtreeview

in our Rad Grid / Rad Tree. It seems like certain people with Chrome 36 (not all people though which is strange and why I put the question here) are having an issue when they try to do any actions on the Grid.. double click etc it loads for a second and doesn't do anything. 

The closest thing I've found is this article on the Chrome boards

https://code.google.com/p/chromium/issues/detail?id=395318

Just wondering if anyone else is having similar issues and have found any work arounds?
Pavlina
Telerik team
 answered on 12 Aug 2014
6 answers
145 views
Other telerik controls that implement IScriptControl support this method.  We use it quite a bit when rendering controls for pdf generation, as it seems to prevent the dreaded "Script control 'xyz' is not a registered script control" when set to false. Since we're generating pdf's, we have no use for the generated scripts anyway.

Can anyone clue me in to why RadBarcode seems does not support RegisterWithScriptManager?  Is it because RadBarcode for some reason *requires* client script activity to function?

We are using the 2012 Q3 version of the telerik tools..
Vasil
Telerik team
 answered on 12 Aug 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?