PDA

View Full Version : [CLOSED] DateColumn issue on grid



Retarian
May 19, 2021, 9:08 AM
Hello friends,

We have another problem again. We are trying to make a grid which has a column with datepicker.
What we need to implement is that column MonthDate to be a datefield which means it will have a datepicker, but we need that datepicker to be actually a MonthPicker like examples from js: https://docs.sencha.com/extjs/6.0.2/classic/Ext.picker.Month.html

For example:
In the current version of code anyhow we have tried to make that column formatting as "yyyyMM", we still cannot make it work on the editrow as:
example: 202105; and the only format which works is: 19/05/2021.

The thing is that as <ext-dateField> is working, see code below:


<ext-dateField fieldLabel="<b>Month</b>" name="NewMonth"
labelAlign="Left"
allowBlank="false"
Format="yyyyMM"
id="Month"
value='DateTime.Today.AddMonths(-1).ToString("yyyyMM")'
maxDate="<%# DateTime.Today %>" />


But as a <ext-dateColumn> or <ext-column> into <ext-gridPanel> is not working and we didnt find a solution to this.

Can you please help us on this problem?


Here is Code for the Grid:


<ext-gridPanel title="Month Grid" id="monthgrid" header="false" frame="true" scrollable="true" minHeight="350">
<store>
<ext-store id="gridstore" data="Model.gridsmodel" autoLoad="true">
<fields>
<ext-dateDataField name="MonthDate" />
<ext-stringDataField name="Comment" />
</fields>
</ext-store>
</store>
<plugins>
<ext-cellEditingPlugin clicksToEdit="1" editing="true" id="edit">
<listeners>
<edit fn="edit" />
</listeners>
</ext-cellEditingPlugin>
</plugins>
<columns>
<ext-dateColumn text="MonthDate" dataIndex="MonthDate" id="MonthDate" editor="datefield" Format="yyyyMM" value='DateTime.Today.ToString("yyyyMM")' maxDate="<%# DateTime.Today %>" />
<ext-column text="Comment" id="Comment" dataIndex="Comment" flex="1" editor="textarea" />
</columns>
</ext-gridPanel>


And here is a screenshot with example for the Month column where the first row is editable and how he needs the data, and the rest of them is an example of how we need the data. (the data is added thru sql for example)
25529

fabricio.murta
May 20, 2021, 4:45 AM
Hello @Retarian!

Can you share the full test case you are trying (of course, the mock values can just come from a constant array instead of SQL). Without being able to reproduce your scenario and know which data is coming and going it is pretty difficult to give you advice on the problem you have.

Looking forward to your follow-up.

Retarian
May 25, 2021, 10:43 AM
Sorry, we were in a hurry with that issue and we solved it using it in other way, for example:
We have added a combobox editorModel in the column and defined it in the same file



@{
var MonthsComboBox = new ComboBox
{
DisplayField = "name",
ValueField = "id",
TypeAhead = true,
QueryMode = "local",
EmptyText = "Select a month...",
Store = new Store
{
Data = DateMonthsData,
Fields = new List<DataField>
{
new DataField() { Name = "id" },
new DataField() { Name = "name" }
}
}
};
}@
<ext-gridPanel title="Month Grid" id="monthgrid" header="false" frame="true" scrollable="true" minHeight="350">
<store>
<ext-store id="gridstore" data="Model.gridsmodel" autoLoad="true">
<fields>
<ext-dateDataField name="MonthDate" />
<ext-stringDataField name="Comment" />
</fields>
</ext-store>
</store>
<plugins>
<ext-cellEditingPlugin clicksToEdit="1" editing="true" id="edit">
<listeners>
<edit fn="edit" />
</listeners>
</ext-cellEditingPlugin>
</plugins>
<columns>
<ext-column text="MonthDate" dataIndex="MonthDate" id="MonthDate" formatter="" editorModel="MonthsComboBox"/>
<ext-column text="Comment" id="Comment" dataIndex="Comment" flex="1" editor="textarea" />
</columns>
</ext-gridPanel>



And now is working.

Really appreciate the response.

fabricio.murta
May 25, 2021, 4:22 PM
Hello again, @Retarian!

Glad you could find another solution that suits you and thanks for sharing it here in forums, we really appreciate it!

When date time parsing and conversion is involved, it matters how data is coming from server and handled client-side, as they are treated as different data types, internally, so it is pretty tough to give you suggestions without a code involving the full lifecycle.

We hope you understand. Keeping a test project or a copy of examples explorer project (https://github.com/extnet/examples.ext.net) handy to experiment and draft test cases may prove really useful in the future.