# Power Table Cell Editor Date Picker

**URL:** <https://forum.inductiveautomation.com/t/power-table-cell-editor-date-picker/14630>\
**Category:** Ignition\
**Created:** [June 26, 2017, 8:00pm UTC](https://forum.inductiveautomation.com/t/power-table-cell-editor-date-picker/14630 "2017-06-26T20:00:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![WildeKurt](https://avatars.discourse-cdn.com/v4/letter/w/50afbb/32.png) [@WildeKurt](https://forum.inductiveautomation.com/u/WildeKurt)\
**Post date:** [June 26, 2017, 8:00pm UTC](https://forum.inductiveautomation.com/t/power-table-cell-editor-date-picker/14630/1 "2017-06-26T20:00:15Z")

</div>

I was able to configure a cell editor to use a date picker. However it throws an error: Can’t import name JCalendar which makes sense because it doesn’t exist. If I remove it, it then can’t find the JCalendar. If I leave it in the cell editor is indeed a calendar type date picker that works fine but throws that error when the table is first loaded. Can’t quite figure out this behavior.

```auto
	from javax.swing import AbstractCellEditor,JCalendar  
	from javax.swing.table import TableCellEditor
	
	if colName == "statusName":
		sel = "SELECT ID,Description FROM Change_Order_Statuses"
		pds = system.db.runQuery(sel)
		opts = []
		for row in pds:
			opts.append((row["ID"],row["Description"]))
		return {"options":opts}
	
	if colName == "StartDate":
		class cellEditor(AbstractCellEditor,TableCellEditor):
			def getTableCellEditorComponent(sel,table,value,isSelected,row,column):
				return JCalendar("A Calendar")
				
		return {'editor':cellEditor()}

```

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [June 26, 2017, 8:38pm UTC](https://forum.inductiveautomation.com/t/power-table-cell-editor-date-picker/14630/2 "2017-06-26T20:38:24Z")

</div>

If the underlying field is an actual date type, the power table will show a calendar popup automatically when you set the field to Editable.

---

<div class="post-metadata">

**Author:** ![cmaynes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmaynes/32/6852_2.png) [@cmaynes](https://forum.inductiveautomation.com/u/cmaynes)\
**Post date:** [March 15, 2018, 5:22pm UTC](https://forum.inductiveautomation.com/t/power-table-cell-editor-date-picker/14630/3 "2018-03-15T17:22:42Z")

</div>

Hey, due to a very specific set of circumstances, I need to create a date picker in a text column.

Can someone answer the OP’s question?

---

<div class="post-metadata">

**Author:** ![phillip.bow](https://avatars.discourse-cdn.com/v4/letter/p/ce73a5/32.png) [@phillip.bow](https://forum.inductiveautomation.com/u/phillip.bow)\
**Post date:** [March 15, 2018, 6:58pm UTC](https://forum.inductiveautomation.com/t/power-table-cell-editor-date-picker/14630/4 "2018-03-15T18:58:24Z")

</div>

Here’s a method of doing this with credit to @nmudge for his approach binding a button to a power table column… but I think if you can avoid it and get the values cast to dates prior to populating your data set that would be a safer approach.

```auto
	# configureEditor() ->

	# magic date column
	if colName == "StartDate":
		from javax.swing import AbstractCellEditor
		from javax.swing.table import TableCellEditor
		from com.inductiveautomation.factorypmi.application.components import PMIDateTimePopupSelector
		
		def onDateChange(e):
			if e.propertyName == "date":
				self.data = system.dataset.setValue(self.data, self.selectedRow, self.selectedColumn, e.newValue)
						
		class MyCellEditor(AbstractCellEditor,TableCellEditor):
			def getTableCellEditorComponent(self,table,value,isSelected,row,column):
				cal = PMIDateTimePopupSelector()
				try:
					cal.setDate(system.date.parse(value))
				except:
					# handle blanks somehow -- this example sets to right now if edited cell is left blank
					cal.setDate(system.date.now())
				
				cal.addPropertyChangeListener(onDateChange)
				return cal
		return {'editor':MyCellEditor()}

```

---

<div class="post-metadata">

**Author:** ![Neha.kabra](https://avatars.discourse-cdn.com/v4/letter/n/e36b37/32.png) [@Neha.kabra](https://forum.inductiveautomation.com/u/Neha.kabra)\
**Post date:** [March 23, 2021, 1:12pm UTC](https://forum.inductiveautomation.com/t/power-table-cell-editor-date-picker/14630/5 "2021-03-23T13:12:53Z")

</div>

Thanks for above solution.  
Got this issue after using above mentioned code.

Exception in thread “AWT-EventQueue-0” NotImplementedError: ‘MyCellEditor’ object does not implement abstract method ‘getCellEditorValue’ from ‘javax.swing.CellEditor’

Kindly help on this to get solution.

---

<div class="post-metadata">

**Author:** ![Wout\_Kolkman](https://avatars.discourse-cdn.com/v4/letter/w/c67d28/32.png) [@Wout\_Kolkman](https://forum.inductiveautomation.com/u/Wout_Kolkman)\
**Post date:** [December 7, 2021, 11:29am UTC](https://forum.inductiveautomation.com/t/power-table-cell-editor-date-picker/14630/6 "2021-12-07T11:29:09Z")

</div>

Try adding these two lines in class MyCellEditor:

```auto
def getCellEditorValue(self):
     return self

```
