Excel pasting issue

2 posts, 0 answers
  1. Frank
    Frank avatar
    16 posts
    Member since:
    Oct 2011

    Posted 24 Feb 2015 Link to this post

    In each cell of my gridview combobox column, I have 2 items ("abc" and "xyz").  In the Excel spread sheet, I have 2 rows, but I am not getting the result when I paste those 2 row into telerik gridview, here are the scenario:

    1. If first row is "abc" and second row is "xyz", result is ok,
    2. If first row is "abc" and second row is "fgh" which "fgh" is not in any of the combobox items, when I paste into gridview, I get "abc" on both rows!

    So it seems that when I paste a value that does not exist in the combobox, it simply pick the "prior" row data (which is valid) and "stuff" it in.  Is there anyway to get "blank" when the value does not exist in the combobox, instead of this "fake wrong data" being stuff in?

    The reason is that the person who pasted does not know that he just pasted a "dirty data" into the grid.  But by making it "blank", the person can see quickly on the screen that there is a "blank" and thus need to pick a valid value.

    I did try to find a way to "validate" the data with the copypaste event of the grid, but the problem is that it seems there is no "finditembytext / value" method like your ASP.NET datagrid.  I was thinking that if during the "pasting" event, I can see if the "copy" value exist in the combobx column (datasource) and if does not exist, 'cancel" the operation.  But again, I don't know what is the "method" to call within the gridview comboboxcolumn object.

    thx!
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 25 Feb 2015 Link to this post

    Hello,

    In order to get the row corresponding to a particular item, I would suggest you using the GetRowForItem method. Generally, the way to control the pasting scenarios is subscribing for the the Pasting and PastingCellClipboardContent events.

    You can find some more test scenarios on the following example from our online github repository: CopyPasteFunctionality. Although GitHub is a very well-known platform we saw a better and easier approach for reviewing our examples developing our brand new SDK Samples Browser. You can install it and then use it to review the examples.

    Regards,
    Dimitrina
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. DevCraft banner
Back to Top