|
Rank: Newbie Groups: Member
Joined: 10/24/2011 Posts: 2
|
I have a EO.Grid on my page based on the example from demo code http://demo.essentialobjects.com/Demos/Grid/Features/Custom%20Column%20-%20Advanced%202/Demo.aspxwhen I click on the row marked * and don't enter or select anything a new item is added to the grid. Is there a way to control that either on client or server side as I don't want the grid to add items that contain nothing.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
The easiest way is to not saving empty rows back to your data source. When the page posts back, you will get a list of new items through the Grid's AddedItems property. You would then loop through that property to check which item is not empty and save it back to your data source (thus skipping empty items). After that you can rebind the Grid from your data source. This process effectively eliminates the empty items.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 10/24/2011 Posts: 2
|
As I understood it's impossiible to take the full control over the grid when it adds new items. That would be great if there was a metod to check if an item being added contains empty cells. If that method returns true then append an item.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, You can do that with our client side JavaScript interface by handling ClientSideAfterEdit event. You would check each cell's value inside that event and then delete the item if all cells are empty. Make sure you call your code from setTimeout. For example:
Code: JavaScript
function your_after_edit_handler(item)
{
setTimeout(function()
{
delete_empty_item(item);
}, 100);
}
function delete_empty_item(item)
{
//check whether the item is empty and delete it if it is
....
}
If you have not used our client side API before, you will need to take a look of this topic: http://doc.essentialobjects.com/library/1/clientapi_howto.aspxHope this helps. Thanks!
|
|