Today I want to share with you a way how to enable upload form excel for custom grid.
Actually this is quite simple -
- Step 1 - define PXImportAttribute on data the data view under the grid.
- Step 2 - enable appropriate Grid Mode (Allow Upload) on the grid properties.
public class CSCalendarMaint : PXGraph<CSCalendarMaint, CSCalendar>
public PXSelect<CSCalendarExceptions> CSCalendarExceptions;
This will enable upload button on the grid action bar with standard functionality.
In some cases, you may want to have more control on the import process. In this case you also may implement optional interface: IPXPrepareItems. This interface should be implemented on processing graph itself.
public interface IPXPrepareItems
bool PrepareImportRow(string viewName, IDictionary keys, IDictionary values);
void PrepareItems(string viewName, IEnumerable items);
bool RowImported(string viewName, object row, object oldRow);
bool RowImporting(string viewName, object row);
- PrepareImportRow - This event will be triggered right before insert record to cache. You can review keys and values that will be assigned to new record.
- PrepareItems - Used to review items before import, but right now does not execute for performance optimizations.
- RowImporting - This and next events will be executed only if you decided bypass update of existing records. On that event you can decide what to do with existing record if it was in the database before, for example delete it.
- RowImported - Here you can control update operation after insert.
Have a nice development!