Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET AJAX > Grid > Excel-like RadGrid

Answered Excel-like RadGrid

Feed from this thread
  • Posted on Sep 27, 2007 (permalink)

    Requirements

    RadGrid for ASP .NET version

    RadControls for ASP .NET AJAX version

    5.0.0 and later


    2011.1.519 and later     

    .NET version

    3.5 and later

    Visual Studio version

    2008 and later

    Programming language

    C#

    Browser support

    all supported by RadGrid for ASP .NET


    all browsers supported by RadControls for ASP .NET AJAX

     
    This code-library project is obsolete. For an updated version click here.

    PROJECT DESCRIPTION
    The sample project demonstrates an Excel-like RadGrid. This resembels entering data in an excel spreadsheet - once you click on a cell, you can enter data in it, without having to invoke the edit command in the standard way. If you scroll down, new items will be added to the control, which will also be in edit mode (inline edit mode).
    The control includes an Update link in the CommandItem, which will call the ItemCommand event handler, where you can include custom code, to update the database, with the values entered so far.

    UPDATED VERSION AVAILABLE BELLOW
    The following example extends the Excel-like RadGrid sample. It adds the "Tab" key navigation,  "Enter" key navigation, single cell click mode, double cell click mode and scroll bar which is always scrolled to the row with selected cell.

    Possible actions which users can perform:

    Mouse actions

    Single mouse click on a cell:
    Marks the cell as selected(single click selection mode). If the user starts writing the text, the content of the cell is replaced with the text entered from the user and the cell is set to the edit mode.
    Double mouse click on a cell:
    Marks the cell as selected in edit mode(double click selection mode). In this mode the user can edit the text into the cell.

    Keyboard navigation

    Left Arrow key is pressed:  
    • If the cell is in single click selection mode:  Selects the left cell.
    • If the cell is in double click selection mode: Moves the caret one position left.
    Right Arrow key is pressed:
    • If the cell is in single click selection mode:  Selects the right cell.
    • If the cell is in double click selection mode: Moves the caret one position right.
    Up Arrow key is pressed:
    • If the cell is in single click selection mode:  Selects the top cell.
    Down Arrow key is pressed:
    • If the cell is in single click selection mode:  Selects the bottom cell.
    "Tab" key is pressed:
    • Selects the right cell.
    "Enter" key is pressed:
    • If the cell is in double click selection mode, selects the bottom cell.
    "Shift" + "Enter" keys are pressed:
    • Selects the top cell.

    Adding rows and saving data

    Adding new row to the RadGrid:
    • Add new row by pressing the "Add New Row" link from the RadGrid Command  item.
    • When the most right and most bottom cell is selected and user press Left arrow or "Tab" key or "Enter" key.
    • When the RadGrid last row's cell is selected and user press Down arrow or "Enter" key.
    Saving the RadGrid data into the database:
    • Save data by pressing the "Save in Database" link from the Grid Command Item. The new inserted rows and the updated rows from the RadGrid are saved in the database.

  • rtk avatar

    Posted on Oct 19, 2007 (permalink)

    Hei
    This is a great example. But i have a bit trouble to get the values on RadGrid1_ItemCommand. How do i get the values from every cell?

    And i would like to set the width of the columns. But it's not working if i use <Columns></Columns>

  • Yavor Yavor admin's avatar

    Posted on Oct 19, 2007 (permalink)

    Hi brajoh,

    To see more information on updating the records, please refer to the following article. Essentially, you can perform a batch update for all the items on the page.

    Kind regards,

    Yavor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

  • rtk avatar

    Posted on Oct 19, 2007 (permalink)

    Thank you for your answer.
    But i get an error now:

    "Specified argument was out of the range of valid values.
    Parameter name: ItemHierarchicalIndex"

    I have a dropdownlist with postback. And my RadGrid1_NeedDataSource are based on selectedvalue in this dropdownlist.

    The first time the page loads it works fine, but if i change the value in the dropdownlist and push the updateAll button i get this error.

  • Yavor Yavor admin's avatar

    Posted on Oct 22, 2007 (permalink)

    Hi brajoh,

    In order yo properly assist you, I would suggest that you open a formal support ticket, and send us a small working project, showing the issue that you described. We will advise you further, as soon as we review it.

    Sincerely yours,
    Yavor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

  • slai avatar

    Posted on Jan 10, 2008 (permalink)

    Is there any update on this thread? I'm having exactly the same problem.

  • slai avatar

    Posted on Jan 10, 2008 (permalink)

    nvm.
    found my answer.
    http://www.telerik.com/community/forums/thread/b311D-bacmba.aspx

  • Paul Haines avatar

    Posted on Jan 23, 2008 (permalink)

    Just thought I'd point out that, you really should check for not being in a postback before updating each GridItem's edit mode. Otherwise, if you have event handlers for the grid's edit controls, the user's selections will be lost on postback.

    Simply wrap the update code in the 'Page_PreRender' routine in the following;
    if (!this.IsPostBack)
    {
        // Original code...
    }

    Hope this helps.
    Paul

  • Yavor Yavor admin's avatar

    Posted on Jan 24, 2008 (permalink)

    Hello Paul,

    Thank you for the suggestion. As the focus of the sample is a little different, we have not considered any similar optimizations. As for the suggestion, this would make a nice addition to the code, however including this option would prevent the items from being put in edit mode, after an update.

    Sincerely yours,
    Yavor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

  • Joe avatar

    Posted on Jan 31, 2008 (permalink)

    I'm interested in a version of this that:

    a.  works with a limited number of columns

    b. works like a windows grid, ie; upon tab off of the last cell in the last row, a new row is automatically added.  the new row is selected and the user may update the cells on the new row.

    c. supports different control types - dropdowns, checkboxes, textboxes.

    If there is anything like this or examples approaching it, please let me know.

  • Yavor Yavor admin's avatar

    Posted on Feb 1, 2008 (permalink)

    Hi Bert,

    Onto your questions:

    1. You can easily limit the number of rows and columns in the control. The logic remains to put all the items in edit mode.
    2. With respect to the second functionality set forth, there is no out-of-the-box solution. You can use the client side api of the control, and use the OnKeyPress event for the control. From within the handler for this event, you can make an AjaxRequest, and get back to the server. From within the server code, you can directly add a new row to the underlying datasource.
    3. The control can include any types of columns, including dropdowns. The main logic remains in updating the underlying database. For more information on similar updates, you can find in the following sample.

    I hope this information helps.

    Kind regards,
    Yavor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

  • Yavor Yavor admin's avatar

    Posted on Mar 10, 2008 (permalink)

    Hi,

    Attached to this thread is an update of the sample, with the latest Prometheus version of the grid.

    Best wishes,
    Yavor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
    Attached files

  • Posted on May 3, 2008 (permalink)

    Hi all,

    Can u provide me with a sample project of using checkboxes in place of textboxes?

  • Yavor Yavor admin's avatar

    Posted on May 7, 2008 (permalink)

    Hello Billu,

    Actually there will not be much difference in the scenario. You will need to add a checkbox column. Additional information on this, you will find in the following example, which also has updates enabled.

    All the best,
    Yavor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

  • Nate avatar

    Posted on Jan 5, 2009 (permalink)

    I am using radgrid version 2008.3.1125.35 and the code from this thread for an excel-like grid.

    Is there a way to navigate the grid using the arrow keys (up/down/left/right) like in excel?

    My grid will handle numbers only so I would like to use the GridNumericColumn which generates RadNumericTextBox's for each cell in the grid. I tried using the OnKeyPress event of RadNumericTextBox but it does not raise events for arrow keys, delete, alt, etc...

    Thanks - Nate

  • Yavor Yavor admin's avatar

    Posted on Jan 6, 2009 (permalink)

    Hello Nate,

    You can use the onKeyPress client side event handler for the grid control, and set focus on the next edited item.

    Kind regards,
    Yavor
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

  • John avatar

    Posted on Jun 5, 2009 (permalink)

    One thing that I am struggling with.  If a user opens more that 1 record and then does anything like sort or group or switch pages, the row comes out of edit mode and thier changes are lost.  Is there a way to stop the rebind for edit rows only and 2 how to remeber values on another page.
    Thanks in advance,
    John

  • Yavor Yavor admin's avatar

    Posted on Jun 8, 2009 (permalink)

    Hello John,

    Indeed, in such a setup the changes will be lost.
    One possible option in this case would be to attach to the ItemCommand event handler, and when a sort command is issued, you can save all the values in the underlying database, and then put the control in edit mode again. In this way, the changes will be persisted.
    I hope this suggestion helps.

    Kind regards,
    Yavor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

  • Tony Sun avatar

    Posted on Jun 13, 2009 (permalink)

    Hi,

    I am newbie to both ASP.NET and Telerik Rad Controls for ASP.NET AJAX.

    With the code.zip, after I unzip there's no solution file I can open.

    I am using VS.NET 3.5 and SQL2005.

    Can someone please give me a instruction on how to open this properly?

    Many thanks.

  • Sebastian Sebastian admin's avatar

    Posted on Jun 15, 2009 (permalink)

    Hello Tony,

    You can choose the File->Open -> Web site option from your VS 2008 and point to the root folder of the example after unzipping it to open the sample in Visual Studio and examine it.

    Best,
    Sebastian
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

  • Yavor Yavor admin's avatar

    Posted on Jun 23, 2009 (permalink)

    Hi,

    Attached to this message, is an updated version of the sample, with the latest version of the controls, which adds additional functionality, such as navigation through the cells with the arrow keys, and adding additional rows when tabbing out of the last row.

    Greetings,
    Yavor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
    Attached files

  • Andy Lo avatar

    Posted on Jun 26, 2009 (permalink)

    Hi,

    Thanks for supplying the sample. But it got some bugs.

    In Deafult.aspx.cs, it dies on Line 42:

    CategoryID.Attributes.Add(

    "onkeydown", "setFocus('" + (RadGrid1.MasterTableView.Items[dataItem.ItemIndex - 1]["CategoryID"].Controls[0] as TextBox).ClientID + "','" + (RadGrid1.MasterTableView.Items[dataItem.ItemIndex + 1]["CategoryID"].Controls[0] as TextBox).ClientID + "','" + "noControl" + "','" + (RadGrid1.MasterTableView.Items[dataItem.ItemIndex]["CategoryName"].Controls[0] as TextBox).ClientID + "');");

    The error message is: Specified argument was out of the range of valid values.
    Parameter name: index

    Can you please let us know how to fix this ASAP? Many thanks

     

  • Yavor Yavor admin's avatar

    Posted on Jun 26, 2009 (permalink)

    Hello Andy Lo,

    I just downloaded the sample and re-tested it, and it worked as expected. Did you perform any special steps to replicate the issue? What is the VS version and browser version?

    Greetings,
    Yavor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

  • Elliott avatar

    Posted on Jun 29, 2009 (permalink)

    Tabbing past the last row does create a new row. But the focus is not on that row.

  • Yavor Yavor admin's avatar

    Posted on Jun 30, 2009 (permalink)

    Hi Elliott,

    You can extend the code, to set the focus on the last, newly added record, when the control renders. In this way, when the newly added record is rendered, the focus will be on the last cell, or the first one, depending on your requirements.
    Let me know how this approach works.

    All the best,
    Yavor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

  • Myriam Intermediate avatar

    Posted on Aug 3, 2009 (permalink)

    How can I enter my columns please?
    Thank you

    Edited: Forgot it! I forgot to add the vb code...Sorry about that

  • Rob Kieft avatar

    Posted on Sep 25, 2009 (permalink)

    Could you tell me what version of the RadControls you are using for this example (excel-like-grid.zip)?  I am using VS2005 with RadControls Q2 2008 and am having a bit of an issue.  Your example works fine, but... I can use the arrow keys and change the values, but the values are not holding (updating the database).  I have a webpage, built very similarly to this Excel-like RadGrid example and it is doing the same thing (not updating the database).

    There is a "sub" called RadAjaxManager_AjaxRequest, which seems to be what controls the "update"?  This could never seems to be getting "triggered" to run.  I put a couple "flags" in that sub to see if it was ever called, and it's not.

    Everything else is working perfectly and exactly how I need it to, except getting what's on the Grid on the screen to update the database table.  I am really stuck on this, so any suggestions you can provide would be much appreciated...

    THANKS!

    -Rob

  • Yavor Yavor admin's avatar

    Posted on Sep 28, 2009 (permalink)

    Hi Rob,

    There may be an issue with the update logic used in your particular example. However, to track this, please open a formal support ticket, and submit a small project, demonstrating the issue. We will review it and advise you further.

    All the best,
    Yavor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

  • Rob Kieft avatar

    Posted on Sep 28, 2009 (permalink)

    Hello Yavor...

    I am using the example that was posted here called "135847_excel-like-grid.zip".  This example does almost exactly the same thing I need to go which is be able to use the arrow keys to "key up" and key down" between different records.  That part works perfectly.  I can change the values in the fields, but the changes are not updating the database (In the example I downloaded from this posting site, it uses a backend "access database" ("Nwind.mdb", table named "Categories").  I can run the app, which brings up the default.aspx page just fine.  I can click on any of fields, change the values, arrow down/up without any problem... But the changes do not seem to be updating the database table "Categories".  There's a routine, RadAjaxManager_AjaxRequest that appears to be what runs the "update" process back to the database.  This does not appear to be getting triggered/fired to run.  I put some additional code in that routine just to let me know if it is being called, and it's not.

    So my question is... Which version of the Telerik RadControls should this example work with?  Which Visual Studio version?  I am using VS2005 with RadControls Q2 2008.  If I could just get your example ("135847_excel-like-grid.zip") working so that the "update" back to the database works, my project should also work without a problem.

    Any help would be greatly appreciated...

    THANKS!

    -Rob

  • Yavor Yavor admin's avatar

    Posted on Sep 30, 2009 (permalink)

    Hi Rob Kieft,

    In the sampe, the ajax request was properly raised. I tested it both with the original and the latest verion of the control. Attached to this message, is a screenshot with a few rows added. Please, take a look at it and verify the information. Also, please keep in mind that the update routine is triggered when the user loses focus of the last cell in the last item of the grid, but this logic can be extended for any other event as needed.

    Greetings,
    Yavor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Attached files

  • yoomee kwon avatar

    Posted on Dec 7, 2009 (permalink)

    How do I execute the project? Is this control or stand-alone page that I can view the sample?

  • Yavor Yavor admin's avatar

    Posted on Dec 9, 2009 (permalink)

    Hello yoomee,

     You can use the latest sample in this message. You can download it, and run it locally. It contains all required resources. You can replace the .dll with the latest available one, or alter the logic further, to meet any custom requirements which you may have.


    Best wishes,
    Yavor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

  • Vince Le avatar

    Posted on Jan 14, 2010 (permalink)


    I executed the updated version and it worked perfectly as I expected, but when I try to switch to design mode, I run into this error:

     system.InvalidCastException: Unable to cast object of type 'Telerik.Web.UI.RadGrid' to Type 'Telerik.Wweb.UI.RadGrid'. at Telerik.Web.Design.RadGridDesigner.get_Grid() at Telerik.Web.Design.RadGridDesigner.GetDesignTimeHtml (DesignerRegionCollection regions) at System.Web.UI.Design.ControlDesigner.GetViewRendering(ConrolDesigner designer)

    Any ideas?

    Thanks.

  • Vince Le avatar

    Posted on Jan 14, 2010 (permalink)


    Never mind.  I recompiled and the error is gone. 

  • Samee Mir avatar

    Posted on Apr 15, 2010 (permalink)

     

     

    hi,

    foreach
    (GridDataItem dataItem in RadGrid3.MasterTableView.Items)

     

    {

     

     

     

    TextBox MetadataId = (TextBox)dataItem["MetadataId"].Controls[0];


    can you please tell me what this line is doing.
     i m reciving an error on this line index out of bound please tell me the solution


    Samee javiad    

     

  • Samee Mir avatar

    Posted on Apr 16, 2010 (permalink)

    hi,
    Can you please explain the code below.

    if

     

     

    (dataItem.ItemIndex == 0)

     

    {

    MetadataId.Attributes.Add(

     

    "onkeydown", "setFocus('" + "noControl" + "','" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex + 1]["MetadataId"].FindControl("MetadataId") as TextBox).ClientID + "','" + "noControl" + "','" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex]["keyWord"].FindControl("KeyWord") as TextBox).ClientID + "');");

     

    keyWord.Attributes.Add(

     

    "onkeydown", "setFocus('" + "noControl" + "','" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex + 1]["KeyWord"].FindControl("KeyWord") as TextBox).ClientID + "','" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex]["MetadataId"].FindControl("MetadataId") as TextBox).ClientID + "','" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex]["keyWord"].FindControl("KwyWord") as TextBox).ClientID + "');");

     

    value.Attributes.Add(

     

    "onkeydown", "setFocus('" + "noControl" + "','" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex + 1]["Value"].FindControl("Value") as TextBox).ClientID + "','" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex]["keyWord"].FindControl("KeyWord") as TextBox).ClientID + "','" + "noControl" + "');");

     

    }

     

     

    else if (dataItem.ItemIndex > 0 && dataItem.ItemIndex < RadGrid3.MasterTableView.Items.Count - 1)

     

    {

    MetadataId.Attributes.Add(

     

    "onkeydown", "setFocus('" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex - 1]["MetadataId"].Controls[0] as TextBox).ClientID + "','" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex + 1]["MetadataId"].Controls[0] as TextBox).ClientID + "','" + "noControl" + "','" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex]["KeyWord"].Controls[0] as TextBox).ClientID + "');");

     

    keyWord.Attributes.Add(

     

    "onkeydown", "setFocus('" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex - 1]["KeyWord"].Controls[0] as TextBox).ClientID + "','" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex + 1]["KeyWord"].Controls[0] as TextBox).ClientID + "','" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex]["MetadataId"].Controls[0] as TextBox).ClientID + "','" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex]["Value"].Controls[0] as TextBox).ClientID + "');");

     

    value.Attributes.Add(

     

    "onkeydown", "setFocus('" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex - 1]["Value"].Controls[0] as TextBox).ClientID + "','" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex + 1]["Value"].Controls[0] as TextBox).ClientID + "','" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex]["KeyWord"].Controls[0] as TextBox).ClientID + "','" + "noControl" + "');");

     

    }

     

     

    else if (dataItem.ItemIndex == RadGrid3.MasterTableView.Items.Count - 1)

     

    {

    MetadataId.Attributes.Add(

     

    "onkeydown", "setFocus('" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex - 1]["MetadataId"].Controls[0] as TextBox).ClientID + "','" + "noControl" + "','" + "noControl" + "','" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex]["KeyWord"].Controls[0] as TextBox).ClientID + "');");

     

    keyWord.Attributes.Add(

     

    "onkeydown", "setFocus('" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex - 1]["KeyWord"].Controls[0] as TextBox).ClientID + "','" + "noControl" + "','" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex]["MetadataId"].Controls[0] as TextBox).ClientID + "','" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex]["Value "].Controls[0] as TextBox).ClientID + "');");

     

    value.Attributes.Add(

     

    "onkeydown", "setFocusOrAddRecord('" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex - 1]["Value"].Controls[0] as TextBox).ClientID + "','" + "noControl" + "','" + (RadGrid3.MasterTableView.Items[dataItem.ItemIndex]["KeyWord"].Controls[0] as TextBox).ClientID + "','" + "noControl" + "');");

     

    }

    i copied this code from the sample project you attached also tell me is this project is done with latest Telerik tools?

    reply me ASAP

    Samee Javaid    

  • Radoslav Radoslav avatar

    Posted on Apr 19, 2010 (permalink)

    Hello Samee,

    Thank you for contacting us.

    The posted code in your first post gets all TextBox controls from all cells in the column with unique name MetadataId.
    The code from your last post attaches the client side event handlers to the onkeydown event on all TextBox controls in each cell on the RadGrid's rows. Also it checks if the DataItem is a first, last or some of a middle rows. Depending on which row is represented by the DataItem, to the client functions setFocus and setFocusOrAddRecord are passed "noControl" string as a first, second, third or fourth parameter.

    Also the code in your last post, is from example which is done with RadControls for ASP.NET AJAX version Q2 2009.

    Additionally it will be helpful if you could send us a simple project that could be used for reproducing the exception described in your first post. Thus we will be able to gather more details about your scenario and provide you with more to-the-point answer.
    Also I suggest you to use the updated version of the Excel-Like RadGrid (excellikegrid-updated.zip). It is the updated version of the previous examples and has more features added in it.

    Looking forward for your reply.

    Regards,
    Radoslav
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

  • Samee Mir avatar

    Posted on Apr 19, 2010 (permalink)

    hi,
    thanks for the reply.
    kindly review my code and tell me where i am wrong,


     

     

    <radG:RadGrid ID="RadGrid1" runat="server" AllowCustomPaging="True"

     

     

     

    AllowFilteringByColumn="True" AllowMultiRowEdit="True"

     

     

     

    AllowMultiRowSelection="True" AllowPaging="True" AllowSorting="True"

     

     

     

    CellPadding="2" CellSpacing="2" DataSourceID="SqlDataSource1" EnableAJAX="True"

     

     

     

    GridLines="None" Height="100px" OnItemCommand="RadGrid1_ItemCommand"

     

     

     

    OnItemCreated="RadGrid1_ItemCreated" OnNeedDataSource="RadGrid_NeedDataSource"

     

     

     

    PageSize="40" Skin="Vista" VirtualItemCount="65536" Width="100%"

     

     

     

    AutoGenerateColumns="False">

     

     

     

    <mastertableview cellpadding="2" cellspacing="2"

     

     

     

    commanditemdisplay="Top" datakeynames="MetadataId" Height="200px"

     

     

     

    datasourceid="SqlDataSource1" editmode="InPlace">

     

     

     

    <filteritemstyle backcolor="#EFEBDE" />

     

     

     

    <commanditemtemplate>

     

     

     

    <asp:LinkButton ID="LinkButton1" runat="server"

     

     

     

    CommandName="UpdateEdited" Text="UpdateChanges"></asp:LinkButton>

     

     

     

    </commanditemtemplate>

     

     

     

    <rowindicatorcolumn>

     

     

     

    <HeaderStyle Width="20px" />

     

     

     

    </rowindicatorcolumn>

     

     

     

    <expandcollapsecolumn resizable="False" visible="False">

     

     

     

    <HeaderStyle Width="20px" />

     

     

     

    </expandcollapsecolumn>

     

     

     

    <Columns>

     

     

     

    <radG:GridBoundColumn DataField="MetadataId" DataType="System.Guid"

     

     

     

    HeaderText="MetadataId" ReadOnly="True" SortExpression="MetadataId"

     

     

     

    UniqueName="MetadataId">

     

     

     

    </radG:GridBoundColumn>

     

     

     

    <radG:GridBoundColumn DataField="KeyWord" HeaderText="KeyWord"

     

     

     

    SortExpression="KeyWord" UniqueName="KeyWord">

     

     

     

    </radG:GridBoundColumn>

     

     

     

    <radG:GridBoundColumn DataField="Value" HeaderText="Value"

     

     

     

    SortExpression="Value" UniqueName="Value">

     

     

     

    </radG:GridBoundColumn>

     

     

     

    <radG:GridBoundColumn DataField="Sheet" HeaderText="Sheet"

     

     

     

    SortExpression="Sheet" UniqueName="Sheet">

     

     

     

    </radG:GridBoundColumn>

     

     

     

    <radG:GridBoundColumn DataField="Row" HeaderText="Row" SortExpression="Row"

     

     

     

    UniqueName="Row">

     

     

     

    </radG:GridBoundColumn>

     

     

     

    <radG:GridBoundColumn DataField="Column" HeaderText="Column"

     

     

     

    SortExpression="Column" UniqueName="Column">

     

     

     

    </radG:GridBoundColumn>

     

     

     

    <radG:GridBoundColumn DataField="ColumnDataType" HeaderText="ColumnDataType"

     

     

     

    SortExpression="ColumnDataType" UniqueName="ColumnDataType">

     

     

     

    </radG:GridBoundColumn>

     

     

     

    <radG:GridBoundColumn DataField="MetaDataType" HeaderText="MetaDataType"

     

     

     

    SortExpression="MetaDataType" UniqueName="MetaDataType">

     

     

     

    </radG:GridBoundColumn>

     

     

     

    </Columns>

     

     

     

    <EditItemStyle BackColor="transparent" />

     

     

     

    <filteritemstyle backcolor="#EFEBDE" />

     

     

     

    </mastertableview>

     

     

     

    <exportsettings>

     

     

     

    <pdf pagebottommargin="" pagefootermargin="" pageheadermargin=""

     

     

     

    pageheight="11in" pageleftmargin="" pagerightmargin="" pagetopmargin=""

     

     

     

    pagewidth="8.5in" />

     

     

     

    </exportsettings>

     

     

     

    <clientsettings>

     

     

     

    <resizing allowcolumnresize="true" allowrowresize="true" />

     

     

     

    <scrolling allowscroll="true" enableajaxscrollpaging="true"

     

     

     

    usestaticheaders="true" />

     

     

     

    <scrolling allowscroll="True" enableajaxscrollpaging="True"

     

     

     

    usestaticheaders="True" />

     

     

     

    <resizing allowcolumnresize="True" allowrowresize="True" />

     

     

     

    </clientsettings>

     

     

     

    <HeaderStyle Width="150px" />

     

     

     

    </radG:RadGrid>

    here is code behind


     

     

     

    protected void RadGrid_NeedDataSource(object source, GridItemEventArgs e)

     

    {

     

     

    int startRowIndex = RadGrid1.CurrentPageIndex * RadGrid1.PageSize;

     

     

     

    int maximumRows = RadGrid1.PageSize;

     

     

     

    int maxColumns = 15;

     

     

     

    DataTable table = new DataTable();

     

     

     

    for (int i = 0; i < maxColumns; i++)

     

    {

    table.Columns.Add(

     

    new DataColumn("Column" + i));

     

    }

     

     

    for (int i = 0; i < maximumRows; i++)

     

    {

     

     

    int index = i + startRowIndex;

     

     

     

    object[] data = new object[maxColumns];

     

     

     

    for (int j = 0; j < maxColumns; j++)

     

    {

    data[j] =

     

    "";

     

    }

    table.Rows.Add(data);

    }

    ((

     

    RadGrid)source).DataSource = table;

     

    }


     

    protected

     

     

    void RadGrid1_ItemCommand(object source, Telerik.WebControls.GridCommandEventArgs e)

     

    {

     

     

    if (e.CommandName == RadGrid.UpdateEditedCommandName)

     

    {

     

     

    //include custom code to update database here

     

    }

    }

     

     

    protected void radtabstrip1_tabclick(object sender, Telerik.Web.UI.RadTabStripEventArgs e)

     

    {

     

     

    if (RadTabStrip1.Tabs[RadTabStrip1.Tabs.Count-1].Selected)

     

    {

     

     

    string sheetname = "sheet" +(RadTabStrip1.Tabs.Count);

     

    Telerik.Web.UI.

     

    RadTab rabtab = new Telerik.Web.UI.RadTab(sheetname);

     

    Telerik.Web.UI.

     

    RadTab rabtabadd = new Telerik.Web.UI.RadTab("+");

     

    RadTabStrip1.Tabs.RemoveAt(RadTabStrip1.Tabs.Count-1);

    RadTabStrip1.Tabs.Add(rabtab);

     

     

    //telerik.web.ui.radpageview radpageview = new telerik.web.ui.radpageview();

     

     

     

    //radpageview.controls.add(radgrid1);

     

     

     

    //radmultipage1.pageviews.add(radpageview);

     

    RadTabStrip1.Tabs.Add(rabtabadd);

    }

    }

    The code is working fine but its not displaying the rows although record is populated in grid.

    I have attached an image of how the grid is being displayed.

    thanks

    Samee Javaid

    Attached files

  • Iana Tsolova Iana Tsolova admin's avatar

    Posted on Apr 19, 2010 (permalink)

    Hi Samee,

    Try removing the Height property you have set to the RadGrid and see if it makes any difference.

    If the problem persists, please open a formal support ticket and send us a sample project illustrating the faced problems there.

    Kind regards,
    Iana
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

  • Mike_T avatar

    Posted on Apr 21, 2010 (permalink)

    Hello,

    When i got the 178616_excellikegrid-updated.zip package and tried to run the solution i'm getting the following error when i hit Save in Database, any hints?

    ExecuteScalar requires an open and available Connection. The connection's current state is closed.

  • Samee Mir avatar

    Posted on Apr 22, 2010 (permalink)

    hi...

    I am using TabStrip and Generating the Tabstrips and Girdviews on run time.I have done all the work but the gridview that is being generated on run time is not editing the cells it is showing Add new Record option in header instead of update Changes. Kindly tell me any Solution. and also see the code below.


     

     

    protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)

     

    {

     

     

    //if (RadTabStrip1.SelectedTab != null)

     

     

     

    // if (!RadTabStrip1.SelectedTab.Text.Equals("+"))

     

     

     

    // {

     

     

     

    // countplus = true;

     

     

     

    // return;

     

     

     

     

    // }

     

    Telerik.WebControls.

     

    RadGrid radGrid = new Telerik.WebControls.RadGrid();

     

    radGrid.ID = controlName =

     

    "radGrid3"; //+ (Session["count"]).ToString();

     

    radGrid.VirtualItemCount = 65536;

    radGrid.PageSize = 40;

    radGrid.AllowPaging =

     

    true;

     

    radGrid.AllowSorting =

     

    true;

     

    radGrid.AllowMultiRowEdit =

     

    true;

     

    radGrid.AllowMultiRowSelection =

     

    true;

     

    radGrid.Skin =

     

    "Vista";

     

    radGrid.GridLines =

     

    GridLines.Both;

     

    radGrid.EnableAJAX =

     

    true;

     

    radGrid.AutoGenerateColumns =

     

    true;

     

    radGrid.ExportSettings.Pdf.PageHeight = 11;

    radGrid.ExportSettings.Pdf.PageWidth = 8;

    radGrid.ClientSettings.Scrolling.AllowScroll =

     

    true;

     

    radGrid.ClientSettings.Scrolling.EnableAJAXScrollPaging =

     

    true;

     

    radGrid.ClientSettings.Scrolling.UseStaticHeaders =

     

    true;

     

    radGrid.MasterTableView.CellPadding = 0;

    radGrid.MasterTableView.CellSpacing = 0;

    radGrid.MasterTableView.CommandItemDisplay = Telerik.WebControls.

     

    GridCommandItemDisplay.Top;

     

    radGrid.MasterTableView.EditMode = Telerik.WebControls.

     

    GridEditMode.InPlace;

     

    radGrid.MasterTableView.RowIndicatorColumn.HeaderStyle.Width = 20;

    radGrid.MasterTableView.ExpandCollapseColumn.Resizable =

     

    false;

     

    radGrid.MasterTableView.ExpandCollapseColumn.Visible =

     

    false;

     

    radGrid.MasterTableView.ExpandCollapseColumn.HeaderStyle.Width = 20;

    radGrid.MasterTableView.EditItemStyle.BackColor = System.Drawing.

     

    Color.Transparent;

     

    radGrid.MasterTableView.FilterItemStyle.BackColor = System.Drawing.

     

    Color.RosyBrown;

     

     

     

     

    //radGrid.MasterTableView.CommandItemTemplate = System.Web.UI.ITemplate.;

     

     

     

    radGrid.AllowPaging =

     

    true;

     

    radGrid.ItemCreated +=

     

    new Telerik.WebControls.GridItemEventHandler(RadGrid1_ItemCreated);

     

    radGrid.NeedDataSource +=

     

    new Telerik.WebControls.GridNeedDataSourceEventHandler(RadGrid_NeedDataSource);

     

     

    e.PageView.Controls.Add(radGrid);

    Session[

     

    "count"] = (int) Session["count"] + 1;

     

    }

     

    protected

     

     

    void Page_Load(object sender, EventArgs e)

     

    {

     

     

     

    Telerik.WebControls.

     

    RadGrid radGrid = new Telerik.WebControls.RadGrid();

     

     

     

    if (controlName != null)

     

    {

    radGrid.ID = controlName;

     

    for (int i = 0; i < radGrid.PageSize; i++)

     

    {

    radGrid.EditIndexes.Add(i);

    }

    }
    }

  • Radoslav Radoslav avatar

    Posted on Apr 23, 2010 (permalink)

    Hi,

    @Michel Hayek
    Please check out the following articles, which explain the described exception:
    http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/d8623a47-1373-48f9-807e-bc00fdcc83f0
    http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_22886044.html
    http://www.dbforums.com/microsoft-sql-server/1616415-executescalar.html
    http://www.velocityreviews.com/forums/t123119-trouble-opening-a-connection-to-sql-2000-db.html

    @ Samee Mir
    I have reviewed the source code which you post. However it is not runnable and I could not reproduce the described issue. Could you please please open a formal support ticket and send us a runnable project (including the database files) which we could debug locally. Thus we will be able to gather more details about your scenario and provide you with more to-the-point answer.

    Regards,
    Radoslav
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

  • Posted on May 4, 2010 (permalink)

    I executed the updated version and it worked perfectly as I expected, but i was not able to group by any column.
    It updated the old Grid to the new Q1 2010 SP1 version.
    Any idea how to get it work?

  • Radoslav Radoslav avatar

    Posted on May 5, 2010 (permalink)

    Hi Markus,

    You could try setting the GridTableView.GroupByExpressions property, however the updated version of the Excel-Like RadGrid has a lot of custom JavaScript code and grouping by any column will cause some functionality to stop working. For example Up, Down navigation with arrow keys will not work as expected. In order to achieve the desired functionality concerning grouping you need to write some custom code to modify the logic of the example.

    All the best,
    Radoslav
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

  • Carlos Diaz avatar

    Posted on May 8, 2010 (permalink)

    Greetings,

    This is a most excellent thread and I thank the Telerik team in advance for the time taken to polish this application as time goes by.  This dedication to support is one of the main reasons Telerik gets my full support. 

    I like the RadGrid, but I don't love it yet.  I have spent a considerable amount of time with it in the past few months (on test projects), but there are many annoying traits that persist.  The trouble starts with my background which is win-forms applications.  Migrating to web forms forces me to reconsider certain issues.  Hierarchical grids have been pretty much the bread and butter of my applications, and one of the major reasons I chose Telerik.  It does a great job in this regard.  However, when it comes to editing, the constant repainting of the web form becomes a major issue.  That page flicker is annoying every time I go back and forth from edit mode.  It creates a lousy user interface experience.  I have tried to implement Ajax to get rid of this annoying flicker but to no avail. I can optimize the response (by the way, thanks for three optimizing video seminars) but it is still not the look and feel that I am after.  I have even considered learning MVC (your MVC behavior is very similar to what I want to achieve), but threads like this one tell me that I might just make Web forms work. 

    I am willing to forgo hierarchical grids to achieve what I am after (could even go as far as one order - one item rule if it speed up data entry).

    An Excel Like behavior is what I am after, but with lots more functionality.   I would like the user to navigate from one cell to another, change the value, then continue to a different cell and repeat the behavior without having to go back and forth from edit mode. Have the changes made checked to some server defined business criteria and saved automatically (i.e. once the user selects a different row or different cell for example - like validation on a win form control)  Maybe changes made to one cell would affect a different cell and it would be nice to have this value updated without repainting the whole page.   I have gone through both this example (excel like grid) and client batch updates http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/clienteditbatchupdates/defaultcs.aspx
    Basically I would be recreating a similar behavior as to a win-form grid.  I have no idea how to do it (without the constant repainting) using the Asp.Net RadGrid (or MVC extensions for that matter).

    Other issues that I would like to see addressed in the example that you have placed for our use in this thread is the use of DropDownLists, NumericOnly, DateTimeSelectors, CheckBoxes and, very important ReadOnly behavior to some selected cells.  ClientEditBatchUpdates has the DropDown lists and also I could work with the names of the controls to implement the ReadOnly behavior.

    It's very cool to download your Excel example and have it running in seconds and say "yes, this is what I am after", only to later find out that there are real-life limitations to how far this example can be taken.  On the first RadGrid optimization video http://tv.telerik.com/aspnet/radgrid/optimizing-radgrid-aspnet-ajax you have a great real life example that addresses the issues I am mentioning here, but, for the life of me can't find a download of that example; so, I know it can be achieved with your grid, but it would be real cool if I could see how you achieved it.

    I can probably work out (actually that's what I am doing now) through lots of trial and error, what can and cannot be done with the Telerik grid.  Your extensive library goes a long way to resolving many of the issues, but with the release of Visual Studio 2010, LinqQ, ASP.NET 4.0 I don't know if I am doing things the old obsolete way or if there are easier ways to do it now.  Take for example Linq vs SQL.  It's not that I can't follow the UpdateDatabase() routine to save changes (I've been doing it this way for years); but, can't I bind the data to a LinqDataSource and save myself so much code writing?  In the Batch-Client edit example you actually bind the controls to a SQLDataSource, in this example you don't.  With SQLDataSource I must pass the UpdateParameters; couldn't I avoid this issue with Linq?  Isn't the reason for the Linq technology precisely this, to avoid all this code writing?  What kind of conflicts do I get when I start mixing Linq and javascript?

    I would like to see an Excel Like Grid for Web Forms tutorial with the following traits (let's not worry about hierarchical for now):
    1) Create the DataGrid like one normally does (of course with the modifications you tell me to add); that is selecting tooltips, header texts, columnd width, filtering behavior for all columns.  In other words, stay away from AutoGenerateColumns.
    2) For those columns that are going to be in constant Excel-Like edit behavior (i.e. not readonly), be able to select the type of entry behavior expected (Text, Numeric (of specific type), checkbox, dropdownlist, datetime).  How would I create them in the Grid during this design time since it's a mixed grid (ReadOnly labels, custom edit controls)?
    3) Implement the common datetime selector for all cells (as recommended in the optimizing video).
    4a) Have a way to validate the data typed in according to business rules after cell exit (including the possibility of changing the value of a separate read-only cell on the same row).
    4b) If 4a cannot be done, then (since now I am using LinQ) I would have LinQ run the validation before updating then repainting the new values (modified to reflect rules if need be) on the row.  This would happen after I leave the row (see 5).
    5) Automatically save changes when I select a different row (or when I press save linkbutton on the command item template).
    6) Have all of this happen without repainting the page.
    7) If possible continue to be able to use Group (together with group footer calculations), Page, Sort, Filter.

    Now, I ask the question; can I do this with ASP.Net RadGrid?  How?  What are the issues that limit this behavior that I am obviously unaware of.  If it cannot be done with ASP.Net RadGrid, can it be done with MVC Telerik extensions? How?  (I would have to learn MVC and Microsoft's tutorials claim that, because of my non-web background I would be more comfortable with webforms; learning new tricks is not an issue -- learning the right ones is)

    Thanks in advance for your guidance concerning these issues.  If they have been addressed elsewhere, I would appreciate the links in a reply so that I may plow through them.  If I can persuade you into writing a test project that covers all these issues and submitting it here, then let me know where to send a keg of beer or a case of wine.

    Carlos

  • Iana Tsolova Iana Tsolova admin's avatar

    Posted on May 11, 2010 (permalink)

    Hello Carlos,

    Thank you for your feedback. We will consider improving the demo respectively.

    However if you want to achieve win-forms behavior in a web application I would suggest you to try RadControls for Silverlight.

    Other than this, you can open a formal support ticket and send us a sample project illustrating your scenario and the faced problems. We will debug it locally and turn back to you with our findings.

    Best wishes,
    Iana
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

  • Carlos Diaz avatar

    Posted on May 11, 2010 (permalink)

    Thanks,

    Didn't know that Silverlight could do the Excel-like RadGrid, thanks, will check up on this.

    Couple of nice things I found out today (sure you can Google them and get them from telerik help, but this is info helpful to this post):

    1)  Changing the display values for Boolean from True False to whatever you need ("Disc." for True, "Av." for False in this example):
    <asp:Label ID="lblDiscontinued" runat="server"   
    Text='<%# Convert.ToBoolean(Eval("Discontinued")) ? "Disc." : "Av." %>' /> 
     

    2) Improving data entry type validation by changing parameters on the numericSetting object:

     

    txtBox = (TextBox)dataItem.FindControl("txtQty");   
    NumericTextBoxSetting numericSetting = (NumericTextBoxSetting)RadInputManager1.GetSettingByBehaviorID("NumberBehavior")   
     
    numericSetting.MinValue = 0;  
    numericSetting.DecimalDigits = 4;  
     
    numericSetting.TargetControls.Add(new TargetInput(txtBox.UniqueID, true));  

     

     

     

    Thanks for the offer on the support ticket.  I've used them before and will use them again in the future as you give us very precise help and useful tips; but would it be possible for you to at least explain why I cannot use a LinqDataSource and must use a SQLDataSource in this example? 

    I might have to create a support ticket, but would appreciate if these two problems are simple and can be answered readily: 
    1) On my demo, If I click on a header to sort, the grid disappears;
    2) I cannot seem to fire the RadAjaxManager1_AjaxRequest.  Placed alert messages before and after $find on ProcessChanges; the one before fires (and the proper Ids string is constructed), the one after $find does not (neither do the SetMessages on the page code, nor can I reach a breakpoint in debug mode).
    Verified line by line to see if I had anything different.  Took away AllowPaging on the RadGrid. Set EnableAjax=True on the RadAjaxManager.  Read this post, saw that another user had same problem, but not the solution.  Don't see how to solve this problem, ran out of ideas.

    Thanks

    Carlos

     

  • Iana Tsolova Iana Tsolova admin's avatar

    Posted on May 14, 2010 (permalink)

    Hello Carlos,

    Indeed, you can bind the grid to LinqDataSource and for more information on how to enable automatic CRUD operations with it, you can check this online demo.

    Regarding your last questions:
        1. Could you please specify on which is the attached demos you are replicating this error?
        2. You can find this article on how to get the client-side object instance of the RadAjaxManager. Pasting the RadAjaxManager declaration and the ProcessChanges method, might help us in finding the source of the issue in your case.

    Best wishes,
    Iana
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

  • Carlos Diaz avatar

    Posted on May 14, 2010 (permalink)

    Hi Iana,

    Oops! (tell you why in a minute). 

    For the Excel Like Grid demo the zip file has 178616 as part of the name.  It's the one that gives the out-of-bound error (to which I added a check on Control.Count > 0 to bypass the error).   In the original downloaded demo, Grid Sort features are turned off.  If I turn Grid Sort, I do get the Grid to sort, however I lose the Excel-like behavior (which I get back if I Add a New record - so I guess I should add some code to return to edit mode after sort or something).  The point is Sort works, the demo works.

    Now to the OOPS part.

    I just realized that my pasts two posts are about this demo:
    http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/clienteditbatchupdates/defaultcs.aspx

    It replicates some of the real cool behavior you have in this Excel-Like Demo, but adds dropdown and checkboxes to the grid.  Also, I can have read-only behavior on some of the columns.  Unfortunately, it is in this demo (not the Excel) that I have trouble getting it to work as advertised (If I enable Ajax - saving works, but sorting does not; viceversa Ajaxrequest never gets fired so no saving, but sort works)

    I just realized this mistake, and I guess the reason was trying to build on the behavior of your Excel-Like model (which is what I am after), but with more RadGrid features that I cove for this project.

    I also realized why use a sqlDataSource or a LinqDatasource is a non-issue as we populate a DataSet for this Excel example.  In the other demo, we use the data stored in the sqlDataSource, but not as nice as with the DataSet and, unfortunately, do not take advantage of the linqDataSource power.

    Still, I used the bit of code you asked me to write out and this is what I get on the ProcessChanges Method:
    Initiated by: RadGrid1
    Updated Controls: RadGrid1 RadInputManager1 Label1
    Initiated by: RadAjaxManager1
    Updated Controls: RadGrid1 RadInputManager1 Label1

    I also set up a breakpoint at the end of RadAjaxManager1_AjaxRequest to see why the page would return a blank page (if I pressed Sort or save the screen would go blank -data saved but not the behavior I expected).  The breakpoint told me that the Grid is recreated, also Radgrid1 Item created followed by Item Templates on Grid and $find in cancelchanges and $find in Processchanges, but after that nothing, blank page.

    I guess the right way will be for me to open a support ticket, but after you suggested Silverlight, I am now in the process of learning about it this weekend and see if this will be a better path.

    Thanks for your help, Telerik does live up to its reputation in this matter.

    Carlos

  • Iana Tsolova Iana Tsolova admin's avatar

    Posted on May 17, 2010 (permalink)

    Hello Carlos,

    I followed the additional information provided, however I was not able to replicate the mentioned issues in the online demo for client edit with batch updates.
    Therefore it would be best to send us a runnable application of the problematic behavior if you decide using RadGrid for ASP.NET AJAX for your purpose.

    All the best,
    Iana
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

  • Posted on May 17, 2010 (permalink)

    I'm testing the excel-like radgrid project with the latest Web.UI version and I have a problem every time I move down passed row number 6 an error is thrown. I found that there is actually a condition in the Script.js (listed below) that checks for row #6 and parse it in a different way, leaving the cell with the wrong ID (null) and causing the error. Same thing happens moving to the right and passing column #10.

    Is there are any reasons for this conditions, am I missing something?
    Can you help me fixing this?

    // Parse the temporary ID's and assaign them to the variables.
    function SetIdParts() {
        var indexOfLastUnderscore = selectedCellId.lastIndexOf("_");
        var subStr = selectedCellId.substr(0, indexOfLastUnderscore);
        var indexOfLastLetter = subStr.lastIndexOf("l");
        var subStrTempI = selectedCellId.substr(indexOfLastLetter + 1, subStr.length - 1 - indexOfLastLetter);
        var subStrTempJ = selectedCellId.substr(indexOfLastUnderscore + 4, selectedCellId.length - 1 - indexOfLastUnderscore);

        // If the row is of the top 6 rows, the id starts with leading 0(zero) symbol.
        // Perform checks to avoid wrong results from parse() function.
        if (subStrTempI[0] == leadingZero) {
            tmpI = parseInt(subStrTempI.substr(1, subStrTempI.length - 1));
        }
        else {
            tmpI = parseInt(subStrTempI);
        }
        // If the column is of the first 10 columns, the id starts with leading 0(zero) symbol.
        // Perform checks to avoid wrong results from parse() function.
        if (subStrTempJ[0] == leadingZero) {
            tmpJ = parseInt(subStrTempJ.substr(1, subStrTempJ.length - 1));
        }
        else {
            tmpJ = parseInt(subStrTempJ);
        }

        firstPart = selectedCellId.substr(0, indexOfLastLetter + 1);
        secondPart = selectedCellId.substr(indexOfLastUnderscore, selectedCellId.length - indexOfLastUnderscore - 2);
    }

  • Radoslav Radoslav avatar

    Posted on May 18, 2010 (permalink)

    Hi Rafael,
    The navigation between inputs depends on the calculating of their id's. For example if the current selected input's ID is RadGrid1_ctl00_ctl11_ctl02, the id of the right cell will be RadGrid1_ctl00_ctl11_ctl03, the id of the bottom cell will be RadGrid1_ctl00_ctl12_ctl02. So the hole RadGrid could be represent as a two dimensional matrix. If the user navigates to right the last two digit will be grown up with one(_ctl02, _ctl03, _ctl04, _ctl05 ...) (respectively index J). If the user navigates to down the middle digits will be grown up with one(  _ctl11_ctl02, _ctl12_ctl02, _ctl13_ctl02, _ctl14_ctl02 ...)  (respectively index I).  However if the current input belongs to the first six rows its ID will be with leading zero(RadGrid1_ctl00_ctl04_ctl01, RadGrid1_ctl00_ctl05_ctl01 ...). When you parse "09"(parseInt("09")), the javascript returns as a result 0 (zero).  So if the input is from the first six rows only the last digit have to be parsed.  
    Also you could check out the attached picture which shows the id's of the inputs into the excel like grid example.

    The problem which you are facing is only under IE7 and it is caused by getting the first char symbol from string (subStrTempI[0]). IE 7 does not support it and it return "unidentified". To achieve the desired functionality you could try replacing the subStrTempI[0] with subStrTempI.substring(0,1):
    // Parse the temporary ID's and assaign them to the variables.
    function SetIdParts() {
        var indexOfLastUnderscore = selectedCellId.lastIndexOf("_");
        var subStr = selectedCellId.substr(0, indexOfLastUnderscore);
        var indexOfLastLetter = subStr.lastIndexOf("l");
        var subStrTempI = selectedCellId.substr(indexOfLastLetter + 1, subStr.length - 1 - indexOfLastLetter);
        var subStrTempJ = selectedCellId.substr(indexOfLastUnderscore + 4, selectedCellId.length - 1 - indexOfLastUnderscore);
     
        // If the row is of the top 6 rows, the id starts with leading 0(zero) symbol.
        // Perform checks to avoid wrong results from parse() function.
        if (subStrTempI.substring(0,1) == leadingZero) {
            tmpI = parseInt(subStrTempI.substr(1, subStrTempI.length - 1));
        }
        else {
            tmpI = parseInt(subStrTempI);
        }
        // If the column is of the first 10 columns, the id starts with leading 0(zero) symbol.
        // Perform checks to avoid wrong results from parse() function.
        if (subStrTempJ.substring(0,1) == leadingZero) {
            tmpJ = parseInt(subStrTempJ.substr(1, subStrTempJ.length - 1));
        }
        else {
            tmpJ = parseInt(subStrTempJ);
        }
     
        firstPart = selectedCellId.substr(0, indexOfLastLetter + 1);
        secondPart = selectedCellId.substr(indexOfLastUnderscore, selectedCellId.length - indexOfLastUnderscore - 2);
    }

    Additionally I am sending you the modified version of the excel-like grid.

    If you need further assistance, do not hesitate to contact us again.

    Kind regards,
    Radoslav
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

  • Neo Edwin avatar

    Posted on May 21, 2010 (permalink)

    I find his control very useful and this is exactly the look and feel and behaviour i was looking for .
    I would like to know if the radgrid supports cell formulas like in an excel? If there is no inbuilt formula support, is there any way by which I can implement my functionality like changing a cell value based on some values in other cells.?

  • Radoslav Radoslav avatar

    Posted on May 25, 2010 (permalink)

    Hi Neo,

    Currently the excel-like grid example does not support cell formulas like in an excel. However you could try implementing this functionality with some custom code. Please check out the following forums threads which elaborate on how to parse the formulas with JavaScript:
    http://www.jguru.com/faq/view.jsp?EID=480122
    http://stackoverflow.com/questions/28256/equation-expression-parser-with-precedence
    http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html

    If you need further assistance, do not hesitate to contact us again.

    Best wishes,
    Radoslav
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

  • Dave avatar

    Posted on Aug 23, 2010 (permalink)

    I am trying to add data validation to the Excel-Like Radgrid.  I am using a radinputmanager.  When I add the grid text boxes to the target controls for the inputmanager I no longer see the current values of the grid.

    How do I add data validation to this?  All Cells must be numeric only.

    public void InstantiateIn(Control container)
    {
        int n = rfdFieldData.ColumnNum;
        string CtlNum = n < 10 ? "0" + n.ToString() : n.ToString();
        txtText = new TextBox();
        txtText.ID = "ctl" + CtlNum;
        txtText.DataBinding += new EventHandler(txtText_DataBinding);
        container.Controls.Add(txtText);
        //RadGrid grid = container.Parent.Controls[0] as RadGrid;
        lblKey = new Label();
        lblKey.ID = "lbl" + CtlNum;
        lblKey.Visible = false;
        lblKey.DataBinding += new EventHandler(lblKey_DataBinding);
        container.Controls.Add(lblKey);
        RadInputManager rim = container.Parent.Parent.Parent.Parent.Parent.FindControl("RadInputManager1") as RadInputManager;
        NumericTextBoxSetting numericSetting = (NumericTextBoxSetting)rim.GetSettingByBehaviorID("NumericBehavior1");
        numericSetting.TargetControls.Add(new TargetInput(txtText.UniqueID, true));
    }

  • Mira Mira admin's avatar

    Posted on Aug 25, 2010 (permalink)

    Hello Dave,

    I tried to replicate the issue which you described, but to no avail.
    Attached to this message, you will find the code which I used for testing.

    Please, take a look at it and let me know if there are any differences at your end, which I may be leaving out.

    All the best,
    Mira
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

  • Dave avatar

    Posted on Sep 1, 2010 (permalink)

    Is it possible to implement Copying from one Column and Pasting into another Column?

  • Radoslav Radoslav avatar

    Posted on Sep 3, 2010 (permalink)

    Hello Dave,

    The excel-like grid implementation demonstrated here does not support the copy & paste functionality from one column to another. The example only demonstrates the basic functionality for showing cells and navigate between them like in MS excel. Also all functionalities is achieved by custom code and they have some limitations.

    Regards,
    Radoslav
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Back to Top

Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET AJAX > Grid > Excel-like RadGrid