iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
The "Paste Multiple Rows from Clipboard" feature sounds great in theory, but in practice we are finding it impossible to implement in a real-world scenario. As far as we can tell, there is no way to highlight bad data inserted into the grid when using this feature.
For example: we have a grid with a mix of numeric, date, text, and valuelist (dropdown) columns. Some of the fields are set to require input. When users enter data in the new row at the top of the grid all of the cells are validated ensuring good values. However, using the "Paste Multiple Rows from Clipboard" feature, users can put in values that are in no way valid, i.e. text in a date field, dates in a numeric field, value list items that are not in the list, and even NULL values in a required field.
Despite the extremely limited amount of documentation on this feature, we have been able to apply some of our own validation using the OnAddPendingChanges client event. However, even though we can blank out celss or apply default values to the added fields, we can find no way to highlight these bad cells to inform the user of the invalid data.
It would be great if we could just run row.Vaidate() or row.GetElement() but we can't access the rows inserted by the multiple row paste feature using GetRow(#) or any other meathod.
How can we highlight (with color) specific inserted cells to denote bad pasted values?
Hi Scott,
Would you kindly run the sample that I attached ? In that sample, I am using Customer Northwind database. What you can do is, try to copy the whole row and paste it again using "Paste Multiple Rows from Clipboard". In here, I make a validation that every city that equals to London will have a red highlight in their cell.
I hope it helps and please do not hesitate to ask if you have any other question. Thank you.
Best Regards,
Andi Santoso
Hi Dan,
Actually, we have a sample with the same similarity. However, in our sample, instead of highlighting the specific column, we put a mark sign on our column which, I believe, is better for UI. You can check it on our live sample. If you browse, you can go to "Browse All Sample"->"WebGrid" -> "Smart Batch Update" -> "Review Changes in Batch Update" or if you go to our C# sample, you can find it under "BatchUpdate_AllowReview.aspx". In there, you can try to copy paste the row and the column, it self, will give us a mark sign if the input is incorret.
I hope it helps and please, do not hesitate to ask if you have any other questions. Thank you.
I think you are failing completely to understand the problem with the multi row paste. Here are the steps to replicate:
1. Open up the sample page you noted above. NOTE that the "Summary" column is required and that the "Duplicate" column accepts number only.
2. Right click in the grid and select the option "Copy this table"
3. Open up a spreadsheet program, such as Excel, and paste the the contents of the table.
4. In Excel, change the value for one of the rows in the "Duplicate" column to the text: "this is not a number"
5. In Excel, in a different row, clear out all text in the "Summary" column.
6. In Excel select and copy all of the data rows. Here is a sample of data to copy:
7. Back in the sample page, right click in the grid and select the option "Paste Multiple Rows from Clipboard".
Note that there is non-numeric content in one of the rows for the "Duplicate" column and that there is an empty value in the "Summary" column for another row. There is no indication presented to the user that any particular pasted rows have bad cells or, better yet, which specific cells are bad.
We need to present to the user an indication that some of the pasted data is invalid - preferably by highlighting the cells or rows in question.
Here, I provide a video attachment and you can download it in here. Would you kindly take a look and correct me if we are not in the same page? I hope it helps and thank you.
*Edit: Finally got the video to run, but it was hard to find a player that would open it . . .
You still do not understand the problem!
In your video you are just pasting into the add row at the top of the grid. Yes, this applies validation. However, you are actually just pasting a single row - even though you have two rows copied.
Follow the exact steps you showed in the video, but when you are ready to paste - do not right-click in the add row.
Instead, right-click on one of the existing rows. You should see a much larger context menu, including options like "Copy Row" and "Copy Table". The option you want to use is clearly labelled, "Paste Multiple Rows from Clipboard". This is where the problem lies. I've attached a screenshot.
Forgive me for the misunderstanding the situation. I am understand now. Here is the sample code to change the background color of the pending changes on WebGrid. However, before do so, on BatchUpDateSetting, you will need to set HighlightChanges="false".
setTimeout(function() { ISGetObject("WebGrid1").RootTable.GetElement(WG40.BODY, WG40.HTMLTABLE).rows[19].cells[2].style.backgroundColor = "Red"; }, 200)
On that code, I go to the last row of WebGrid, which is the 19th rows and get the second cell to change the background color into red.
I hope it helps and please let me know if you have any other questions. Thank you.
Hi Andi,
Dan is in meetings today but we wanted to get back to you. We've taken the code you provided and tried to implement it. The problem is we do not know what row/cell indexes we will need to adjust ahead of time. We are doing our validation in the 'OnAddPendingChanges' client side event. We can only access the row using the 'rowChanges' variable. We tried to implement your code using the index values from 'rowChanges' but it is not possible. The cell index does not exist for these cells and these rows always have a position of 0. We tried to assign the style changes directly using rowChanges.Row.Cells.GetNamedItem('CellName').style.backgroundColor = "Red"; but the style attribute does not exist for these pending changes rows, neither does the cellElement attribute. There doesn't seem to be any way to get the index or change the style using OnAddPendingChanges's 'rowChange' attribute. If we are missing something in here please let us know.
Thanks,
Scott French
Yes, unfortunately using OnAddPendingChanges's 'rowChange' attribute does not support of style property, that is why on my previous code, I was using an element to get the style of particular row and cell. The best workaround, I believe, is by adding validation for each cell. You can get the value of the changed row by using this following code:
rowChange.Row.GetCells().GetNamedItem("Field1").Get("Value") == "ValidationValue"
I hope it can help and please do not hesitate to ask if you have any other questions. Thank you.
We aren't having any trouble getting the values and performing our own validation at the cell level. The problem is once we find out a value is incorrect we have no way to mark the cell or row visually to let the user know a change is required. The other issue that needs to be dealt with eventually is why these incorrect values are allowed to be inserted at all... the rules setup by at the column level should stand as Dan stated in his original post. For now we need some kind of method to mark the values we have tested in our own custom code as invalid. Our testing shows there is no row index or cell index provided for any of the rows are created when a multi-row paste function is performed. That means we couldn't use the code you provided that updated the HTML elements. Now you've confirmed the style element doesn't exist for these mulit-paste rows. Are there any options left for marking these invalid cells?
Thanks,Scott French
Hi Scoot,
Actually, we do have a method to prevent invalid data insertion. Here are the sample code that will prevent data insertion to pending changes if it meets its validation. You can put this code in client side OnAddPendingChanges event.
if (rowChange.Data[1].NewValue == "Value") { //If it is true, it will undo the changes setTimeout(function() {rowChange.Row.UndoChanges();},200); }
Imagine this situation. A user visits the page in order to post 50 very similar looking rows that have been stored in a spreadsheet. They will copy these rows then paste them into the grid. Here is our problem, we do not want the grid to drop rows with bad values because it may be very hard to tell which rows have been dropped. If the user pastes 50 rows but only 30 show up in the grid how are they to know which rows contained the bad values? How will they know which cells within the row require correction? We want the rows to be inserted into the grid but have any bad cell values highlighted. We know how to do our own validation, we know how to blank out the bad cells values, we know how to prevent the row from being inserted. We just have no way to keep the row and mark the bad values. Without this functionality we really can't move forward with this setup. Please let me know about marking these cells that contain bad data.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname