Disable the dates that appear in the date column while modifying a cell in the material user interface’s datepicker

I am using a date column in AgGrid React, and this column displays the dates. What I need is that
Datepicker opens when I change any cell in the date column; the dates that are showing in every cell should be blocked so that it only shows the dates that aren’t in the data I’m passing.

enter image description here As can be seen in the photograph, I am able to pick the date December 1, 2023, but I am passing that date in the dates array and it is also displayed in the date column cell. Therefore, I need to disable December 1, and the dates that are not in the dates array should be selectable.Also set the data to be sent to the api inside the handle. Using the variable overridePrice, the CellValueChanged method

const HisData = (hisData Props: HisData Props) => {

  const dataRef = useRef<AgGridReact<
    ShowMarketDataResponseType[]
  > | null>(null);
  const [updatedData, setUpdatedData] = useState<
    ShowMarketDataResponseType[] | undefined
  >([]);
  const [overRiddenPrice, setOverRiddenPrice] = useState<
    OverridePriceRequestType[]
  >([]);
  const [rowData, setRowData] = useState<ShowMarketDataResponseType[]>();
  const [selectedRowsIndex, setSelectedRowsIndex] = useState<number | null>(
    null
  );

  const dates = gridMarketData?.map((dt: ShowMarketDataResponseType) => {
    return dt.date;
  });
  data for dates = [
    "2023-12-01",
    "2023-12-02",
    "2023-12-03",
    "2023-12-04",
    "2023-12-05",
    "2023-12-06",
    "2023-12-07",
    "2023-12-08",

]

  const handleCellValueChanged = (params: any) => {
    const { data } = params;
    const overridedPrice: OverridePriceRequestType[] = [...overRiddenPrice];
    overridedPrice.push(data);
    setOverRiddenPrice(overridedPrice);
  };

  const gridOptions = {
    columnDefs: [
      {
        field: "date",
        headerName: "Date",
        minWidth: 200,
        type: "numericColumn",
        wrapHeaderText: true,
        editable: (params: any) => {
          if (params.data.date !== "") {
            const exists = gridMarketData?.some(
              (record: ShowMarketDataResponseType) =>
                record.date === params.data.date
            );
            return !exists;
          }
          return params.data.date === "";
        },
      },
      {
        field: "price",
        headerName: "Price",
        minWidth: 210,
        type: "numericColumn",
        wrapHeaderText: true,
      },
    ],
  };
  const defaultColDef = useMemo<ColDef>(() => {
    return {
      sortable: true,
      resizable: true,
      filter: true,
      flex: 1,
      menuTabs: ["generalMenuTab", "filterMenuTab"],
      shownorowsoverlay: true,
      unSortIcon: true,
    };
  }, []);


  const onPriceSave = () => {
    overridePriceSaveCallback(overRiddenPrice);
    setOverRiddenPrice([]);
  };

  const handleOverridePriceCancel = () => {
    setUpdatedData(cloneDeep(gridMarketData));
    setOverRiddenPrice([]);
    setSelectedRowsIndex(null);
  };

  useEffect(() => {
    setUpdatedData(cloneDeep(gridMarketData));
  }, [gridMarketData]);

  return (
    <MuiBox className="tw-h-auto tw-max-h-full">
      <MuiGrid
        container
        item
        className="tw-grid md:tw-grid-cols-2 sm:tw-grid-cols-2 lg:tw-grid-cols-2 tw-grow"
      >
        <MuiGrid
          item
          className="tw-flex tw-m-1 md:tw-grid-cols-2 sm:tw-grid-cols-2 lg:tw-grid-cols-2 md:tw-justify-end lg:tw-justify-end sm:tw-justify-end"
          alignItems="center"
        >
          <MuiButton
            className="tw-bg-slate-75 tw-text-xs"
            onClick={onPriceSave}
            disabled={overRiddenPrice.length === 0}
          >
            Save
          </MuiButton>
          <MuiButton
            className="tw-bg-slate-75 tw-ml-3 tw-text-xs"
            onClick={handleOverridePriceCancel}
          >
            Cancel
          </MuiButton>
        </MuiGrid>
      </MuiGrid>
      <div className="fx-conduit-container tw-w-full tw-h-full tw-flow-root ag-theme-alpine tw-mt-1">
        {updatedData && updatedData.length > 0 ? (
          <AgGridReact
            ref={dataRef }
            rowData={updatedData}
            columnDefs={gridOptions.columnDefs}
            defaultColDef={defaultColDef}
            editType={"fullRow"}
            onCellValueChanged={handleCellValueChanged}
            pagination
            suppressDragLeaveHidesColumns
            stopEditingWhenCellsLoseFocus
            suppressCellFocus
            paginationPageSize={15}
            paginationPageSizeSelector={[5, 15, 20]}
            domLayout="autoHeight"
            rowSelection="single"
            onSelectionChanged={onRowSelectionChanged}
          />
        ) : (
          <div className=" tw-flex tw-items-center tw-justify-center">
            <div className="tw-max-w-sm tw-p-4">
              <div className="tw-text-xs tw-text-center">
                <span>{noDataMessage}</span>
              </div>
            </div>
          </div>
        )}
      </div>
    </MuiBox>
  );
};

export default HistoricalData;

Please refer to the code and let me know if anyone has a solution.

New contributor

aditya Gaikwad is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật