Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
143 views
Greetings,

I'll try to be clear as possible in describing this problem as I couldn't catch its cause until I did long debugging inside Rad controls' code.

What I'm trying to create is a serial column (1, 2, 3, …) that keeps its proper serialing with the user deleting from and adding to the grid in batch mode.
The logic is very simple. I added a handler to the RowCreated event as follows:

grid.add_rowCreated(function (sender, args)
    {
        var item = args.get_item();
 
        if(Edge.UI.GridExtensions.isNewRow(item))
            Edge.UI.GridExtensions.setCellValue(item, uniqueName, Edge.UI.GridExtensions.SerialColumn.getMaxSerialValue(tableView, uniqueName) + 1);
    });
 
Edge.UI.GridExtensions.SerialColumn.getMaxSerialValue = function (tableView, uniqueName)
{
    var max = Number.NEGATIVE_INFINITY,
        dataItems = tableView.get_dataItems();
 
    if(dataItems && dataItems.length)
    {
        for(var i = dataItems.length; i--;)
        {
            var value = parseInt(Edge.UI.GridExtensions.getCellValue(dataItems[i], uniqueName));
 
            if(value > max)
                max = value;
        }
    }
 
    return max === Number.NEGATIVE_INFINITY ? 0 : max;
}

The relevant part is the line marked with bold and italic (dataItems = tableView.get_dataItems())

Here's the sequence I do to reproduce the problem:
  1. I start with an empty grid, then click the "Add New" button.
  2. The button calls BatchEditingManager.addNewRecord which in turn calls GridTableView.createItem.
  3. createItem creates the TR element and appends it to the DOM and creates a GridDataItem object for it.
  4. Then, near the end of the method body, come two lines of code who cause the problem:
    p._owner.raise_rowCreated(new Telerik.Web.UI.GridDataItemEventArgs(n, null));
    Array.insert(e, k, d);
    I extracted these from the minified code with the usage of chrome developer tools' pretty print feature. You may find them using the find functionality of your text editor. The first line calls my event handler, which calls get_dataItems (the line in bold in the first code block). Inside get_dataItems the code checks the length of the internal _dataItems array:
    if (this._dataItems.length > 0 || (this._cachedItems && this._cachedItems.length > 0)) {
                return this._dataItems;
            }
    Of course it finds the length equal to zero because the GridDataItem object wasn't added to the array yet in createItem. The code then goes into initialising the _dataItems array from the TR elements:
    var o = ($telerik.isOpera) ? this.get_element() : this.get_element().tBodies[0];
            var n = o.rows;
            for (var c = 0, k = n.length;
            c < k;
            c++) {
                
                this._owner.raise_rowCreating(new Sys.EventArgs());
                
                if (!b) {
                    b = $create(Telerik.Web.UI.GridDataItem, {_owner: this,_data: a}, null, null, m);
                }
               
                this._dataItems[this._dataItems.length] = b;
                this._owner.raise_rowCreated(new Telerik.Web.UI.GridDataItemEventArgs(m, null));
            }
    I replaced the irrelevant parts with ellipsis. This code adds a GridDataItem object to the array then raises the RowCreated event (which is the proper behaviour), but I wonder why isn't the event raised inside the if(!b) block? If the b object exists from a previous initialisation, why raising the RowCreated event for it again? The last piece of code causes my event handler to be called again and my serial result to be wrongly evaluated (it returns 2 instead of one), but this is not the main problem.
  5. After all that code executes, the _dataItems array now have two objects for the same TR element (one created by createItem and the other created by the get_dataItems accessor), if I remove the single grid row using BatchEditingManager.deleteRecord the grid remains with an orphan GridDataItem object.

After this, the grid stops working. When I try adding new lines, an exception erupts. I don't know certainly the cause, but it should be because of the orphan item.

After the description of the problem, I'd like to say that some accessors in the Rad controls code involve a lot of work which shouldn't be the nature of accessors. I have some places where get_dataItems raises exceptions, and I had no means to avoid but a nasty dummy try/catch

try
    {
        gridDataItems = this.tableView.get_dataItems();
    } catch(dummy)
    { }

أشرف
Top achievements
Rank 1
 answered on 17 Dec 2013
1 answer
92 views

Hi, I have this RadGrid whose data can be edited; the problem is that when moving between pages the data is lost because NeedDataSource event is triggered if the user doesn't click on an OK button, the data is not saved.

This is the grid definition:
 <telerik:RadGrid ID="Grilla" runat="server" Height="570px" OnNeedDataSource="LeeDatos"
                PageSize="20"  SkinID="Grilla2" Width="775px" GridLines="None"   ClipCellContentOnResize="true"
                TableLayout="Auto">
(etc)

So I changed PageSize to "9999" but now the grid is displayed all in a single page but when I click on Ok I have this message:

Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500

(seems to happen with a PageSize greater then 190, according to tests).

No matter if I click on Ok or Cancel buttons (in a Telerik.Web.UI.RadToolBar), the same error is thrown.

Any hint?

Thanks
Princy
Top achievements
Rank 2
 answered on 17 Dec 2013
1 answer
28 views
I see the demo can do Dates on the header. However, we need it to show 1 single day with the times running from left to right in the header. Is the screenshot attached possible?
Shinu
Top achievements
Rank 2
 answered on 17 Dec 2013
1 answer
82 views
When I view the demo AsyncUpload - Validation, clicking Select opens a file dialog with the files filtered by the extensions. Yet according to the source, it does not make use of File Filtering.

A similar project found at the bottom of this thread also specifies AllowedFileExtensions, but no filtering occurs. How does the online demo perform the filtering?
Shinu
Top achievements
Rank 2
 answered on 17 Dec 2013
3 answers
122 views
Hi,

I wonder if we could add multiple handlers to the 'OnClientBlur' event, if yes, could you please reply me with a sample.

Thanks,
Ramesh
Princy
Top achievements
Rank 2
 answered on 17 Dec 2013
1 answer
116 views
I am having an issue with TreeList not returning any results whenever I use a string DataKeyNames value. For type int it works as expected.

For the sake of this example, I used an int key but simply added a facade string GET on top of it to verify that once string data type is used it fails.

Am I doing something incorrectly?



Complete ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TreeListStringKey.aspx.cs" Inherits="LiveExamples_Services_Audit_TreeListStringKey" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <rei:REIRadScriptManager ID="REIRadScriptManager1" runat="server" ScriptMode="Release" LoadScriptsBeforeUI="true">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
        </Scripts>
    </rei:REIRadScriptManager>
    <div>
        <telerik:RadTreeList ID="tree" runat="server" OnNeedDataSource="Tree_NeedDataSource" ParentDataKeyNames="RealParentId" DataKeyNames="RealId"
            AllowPaging="true" PageSize="1000" AutoGenerateColumns="false" AllowSorting="true" EnableEmbeddedSkins="false" Skin="EHB">
            <Columns>
                <telerik:TreeListBoundColumn UniqueName="SectionName" DataField="SectionName" HeaderText="Section" />
                <telerik:TreeListBoundColumn UniqueName="ActionTaken" DataField="ActionTaken" HeaderText="Action" />
                <telerik:TreeListTemplateColumn UniqueName="ModifiedDate" HeaderText="Modified Date">
                    <ItemTemplate>
                        <%# (DateTime)Eval("ModifiedDate") == DateTime.MinValue ? "" : Eval("ModifiedDate") %>
                    </ItemTemplate>
                </telerik:TreeListTemplateColumn>
                <telerik:TreeListBoundColumn UniqueName="ModifiedBy" DataField="ModifiedBy" HeaderText="Modified By" />
                <telerik:TreeListBoundColumn UniqueName="Value" DataField="Value" HeaderText="Value" HeaderStyle-Width="45%" />
            </Columns>
        </telerik:RadTreeList>
    </div>
    </form>
</body>
</html>



COMPLETE ASPX.CS
using System;
using System.Collections.Generic;
using System.Globalization;
using Telerik.Web.UI;
 
public partial class LiveExamples_Services_Audit_TreeListStringKey : System.Web.UI.Page
{
    public class FlatRevision
    {
        public int Id { get; set; }
        public int ParentId { get; set; }
 
        public string RealId { get { return Id.ToString(CultureInfo.InvariantCulture); } }
        public string RealParentId { get { return ParentId.ToString(CultureInfo.InvariantCulture); } }
 
        //public double RealId { get { return (double)Id; } }
        //public double RealParentId { get { return (double)ParentId; } }
 
 
        public string SectionName { get; set; }
        public DateTime ModifiedDate { get; set; }
        public string ModifiedBy { get; set; }
        public string Value { get; set; }
        public string ActionTaken { get; set; }
        public RevType Type { get; set; }
    }
    public enum RevType
    {
        Section = 1,
        Revision = 2
    }
 
 
    protected void Tree_NeedDataSource(object sender, TreeListNeedDataSourceEventArgs e)
    {
        tree.DataSource = new List<FlatRevision>
            {
                //sv report
                new FlatRevision { Id = 1, ParentId = 0, SectionName = "Site Visit Report", Type = RevType.Section },
                new FlatRevision { Id = 2, ParentId = 1, SectionName = "Key Findings", Type = RevType.Section },
                //kf r1
                //new FlatRevision { Id = 3, ParentId = 2, SectionName = "Revision", Type = RevType.Section, ModifiedBy = "Willis", ModifiedDate = DateTime.Now.AddDays(-2) }, //removing "revision" rows per Venkat
                new FlatRevision { Id = 4, ParentId = 2, SectionName = "Key Finding - ADAP", Type = RevType.Section, Value="Type: ADAP", ActionTaken = "Updated"},
                new FlatRevision { Id = 5, ParentId = 2, SectionName = "Key Finding - Financial Assessment", Type = RevType.Section, Value="Type: Financial Assessment", ActionTaken = "Updated" },
                //kf r2
                //new FlatRevision { Id = 6, ParentId = 2, SectionName = "Revision", Type = RevType.Section, ModifiedBy = "Jimmy", ModifiedDate = DateTime.Now.AddDays(-1)},//removing "revision" rows per Venkat
                new FlatRevision { Id = 7, ParentId = 2, SectionName = "Key Finding - Financial Review", Type = RevType.Section, Value="Type: Financial Review", ActionTaken = "Added" },
                 
 
                //sv questionnaire
                new FlatRevision { Id = 8, ParentId = 0, SectionName = "Post Site Visit Questionnaire", Type = RevType.Section },
                new FlatRevision { Id = 9, ParentId = 8, SectionName = "1. Were there any updates made to the site visit agenda at the entrance conference with the organization? ", Type = RevType.Section },
 
                //simple checklist revision
                //new FlatRevision { Id = 10, ParentId = 9, SectionName = "Revision", Type = RevType.Section, ModifiedBy = "Jasper", ModifiedDate = DateTime.Now.AddDays(-4).AddMinutes(-29) }, //removing "revision" rows per Venkat
                //new FlatRevision { Id = 11, ParentId = 10, SectionName = "Checklist Question", Type = RevType.Section },
                new FlatRevision { Id = 12, ParentId = 9, SectionName = "Answer", Type = RevType.Section, Value = "Yes", ActionTaken = "Updated"},
                new FlatRevision { Id = 13, ParentId = 9, SectionName = "Comment", Type = RevType.Section, Value = "pajama pajama pajama pajama pajama pajama pajama pajama pajama pajama", ActionTaken = "Updated"},
                new FlatRevision { Id = 14, ParentId = 9, SectionName = "Agenda Documents", Type = RevType.Section},
                new FlatRevision { Id = 15, ParentId = 14, SectionName = "Document - 'Bananas.txt'", Type = RevType.Section, ActionTaken = "Added"},
                new FlatRevision { Id = 16, ParentId = 15, SectionName = "Document Name", Type = RevType.Section, Value="Bananas.txt"},
                new FlatRevision { Id = 17, ParentId = 15, SectionName = "Document Size", Type = RevType.Section, Value="5kb"},
                new FlatRevision { Id = 18, ParentId = 15, SectionName = "Document Description", Type = RevType.Section, Value="This is the file that contains useful information about bananas."},
                new FlatRevision { Id = 19, ParentId = 14, SectionName = "Document - 'Fish.txt'", Type = RevType.Section, ActionTaken = "Updated"},
                new FlatRevision { Id = 20, ParentId = 19, SectionName = "Document Name", Type = RevType.Section, Value="Fish.txt"},
                new FlatRevision { Id = 21, ParentId = 19, SectionName = "Document Size", Type = RevType.Section, Value="332kb"},
                new FlatRevision { Id = 22, ParentId = 19, SectionName = "Document Description", Type = RevType.Section, Value="All about fish."},
            };
    }
}

Justin
Top achievements
Rank 1
 answered on 16 Dec 2013
4 answers
222 views
I have created the orgchart and it is in it's own page for printing purposes, but when I print it in IE8/9/10 it only will print a portion of the chart.  It will not extended to multiple pages so we can print it to either PDF or a printer.  How can I achieve this? 
Juan
Top achievements
Rank 1
 answered on 16 Dec 2013
1 answer
57 views

Hello, is there a way to save out the users currently selected "view" of the pivotgrid, and then reload it?

I'd like to let my users build out views and then save them for later.



I couldn't find any examples of this in your samples.



thx

Viktor Tachev
Telerik team
 answered on 16 Dec 2013
1 answer
61 views
Hello My Dear Friends all telerik developer;


protected
void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack) return;
 
            SessionClear();
 
            if (Request.QueryString["portCekKartID"] != null)
            {
                string masterId = Request.QueryString["portCekKartID"].ToString();
                int id = Convert.ToInt32(masterId);
                UpdateFormControl(id);
            }
                                      //CekDurumTips = Enum
 
            if (CekDurumGetir(masterId) != CekDurumTips.EldenTahsil)
            {
                Show("Error !");
 
                //Radwindow not opened
 
                return;
 
            }
            else
            {
                //radwindow oppen
            }
 
        }



Radwindow
<telerik:RadWindow ID="radwindowPortCekGeriAl" AutoSize="false" OnClientBeforeClose="pageReflesh" Title="Cirolanmış Çekleri Geri Al"
                   runat="server" Animation="FlyIn" Behaviors="Default">
               </telerik:RadWindow>

JavaScript Radwindow open commend
function rightClickHandler(sender, args) {
 
                    var menuItemValue = args.get_item().get_value();
 
                    if (menuItemValue == "portCekGeriAl") {
                        var rowID = $("#radGridClickedRowIndex2").val();
                        openPopupPortfoyeGeriAl(sender, rowID);
 
                    }
                }


Javascript open Method
function openPopupPortfoyeGeriAl(sender, selectID) {
                    var width = parent.innerWidth - ((parent.innerWidth / 6) * 2);
                    var height = parent.innerHeight - (parent.innerHeight / 4);
                    var left = innerWidth / 9;
                    var top = 0;
                    radopen("/PortfoyeGeriAl.aspx/?portCekKartID=" + selectID, "radwindowPortCekGeriAl", width, height, left, top);
 
                }


After clicking the button you want to check on the server side radwindow opening popup
is server side error  = popup not open
is server side succes = popup open
staffed with JavaScript, but I need to check on the server side.

Not: I'm sorry my bad english :(


Marin Bratanov
Telerik team
 answered on 16 Dec 2013
1 answer
127 views
I have a radgrid that is using edit mode ="batch" mode the problem is when i select the cell for edit the grid the controls width is too big and i cannot see my time picker so how can i change the width of the control.

see the attached image.
  
Angel Petrov
Telerik team
 answered on 16 Dec 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?