English 中文(简体)
• 贵国如何制定材料、数据、数据、初步国家数据输入模型以备日期?
原标题:How do you setup Material UI DataGrid Initial State Filter Model for Date?

我想提供一个带有初步过滤模型的马塔基纳数据网,因此只显示即将到来的日期。 (在用户清除缺损装置过滤器之前)

I have no problems creating a filter for the date after the datagrid is loaded without any initialState set. manually setting filters after rendered datagrid

<However!> 当我尝试了涉及日期栏的初步过滤模型时

initialState = {{
     filter: {
          filterModel:{
               items: [{
                    columnField:  class_end_date ,
                         operatorValue:  onOrAfter ,
                         value: new Date()
               }],
           }
     }
}}
     

I continually get Uncaught TypeError: filterItem.value.match is not a function top of the stacktrace

buildApplyFilterFn gridDateOperators.js:10
getApplyFilterFn gridDateOperators.js:62

https://i.stack.imgur.com/xenod9.png”rel=“nofollow noreferer”> 缺损过滤模型产生的误差

I am assuming there s some kind of type conversion I need for the value property in the items filter object. Still researching, but I can t find anything helpful in MUI docs hence far. If anyone has tackled this one I d be grateful for a step in the right direction! Thank you.

我还确保了我的类型和价值 在我的栏目阵列中适当界定了光。 摘录

{
            field:  class_start_date ,
            headerName:  Start Date ,
            width: 140,  
            type:  date ,
            valueGetter: (params) => {
                return new Date(params.value)
            }
          
        },
        {
            field:  class_end_date ,
            headerName:  End Date ,
            width: 140,  
            type:  date ,
            valueGetter: (params) => {
                return new Date(params.value)
            }
        },

I ve also tried using dateTime for the column type, formatting the dates from the valueGetters and the filtermodel value to mm/dd/yyyy format, and I tried ensuring the value property was a string

filterModel:{
               items: [{
                    columnField:  class_end_date ,
                         operatorValue:  onOrAfter ,
                         value: `${new Date()}`
               }],
           }
最佳回答

有趣的是,将今天的日期改为yyy-mm-d 扼杀是骗局。

我的看法是,虽然“倡议”的价值很高。 更优惠的返回日期的标的是在过滤器的比较后将其改成一个阵列。

initialState = {{
      filter: {
        filterModel:{
             items: [{
                 columnField:  class_end_date ,
                 operatorValue:  onOrAfter ,
                 value: `${formatDate(new Date())}`
             }],
        }
   }
}}

WHERE格式 日期是地雷的有用功能,该功能转化成yyy-mm-d

问题回答

截至MUI v5:

initialState: {
            filter: {
              filterModel: {
                items: [{
                  field: "status",
                  operator: "is",
                  value: "NEW"
                }]
              }
            }
          }

Datagrid Docs 这里说,我们可以采用最初的那种模式来启动。 国家推进。

这为我工作:

initialState={{
       sorting: {
           sortModel: [{ field: "date", sort: "desc" }],
            },
          }}

希望会有所助益。





相关问题
Mysql compaire two dates from datetime?

I was try to measure what is faster and what should be the best way to compare two dates, from datetime record in MySql db. There are several approaches how to grab a date from date time, but I was ...

iPhone Date Picker rolls over to 2010 on December 27th?

So I implemented a UIDatepicker in one of my applications for scheduling and autodialing teleconferences... everything is pretty much ready to go except, while testing I noticed that when the date ...

Convert date Python

I have MMDDYY dates, i.e. today is 111609 How do I convert this to 11/16/2009, in Python?

specifying date format when using $form->inputs() in CakePHP

I am wondering if there is a way to specify the date format in the forms created using CakePHP s $form->inputs(); Please note that this is not the individual $form->input() but instead $form->inputs() ...

NSDateFormat, super simple! Where am I screwing up?

Ok, this is really simple, maybe I m a getting a bit burnt out, but seems like it should work, Query XML feed, put out date string, format, display in a cell. The issue is I m a getting a NULL ...

sqlite writing a date into an email

I am exporting a date value from sqlite and placing it into an email. The date appears like this 279498721.322872 I am using Objective C in an Iphone App. Does anyone know how to make this export ...

热门标签