jQWidgets Forums

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts

  • shadymaster1011
    Participant

    Hi I am using React js version 22.0.0 to use JQX forms , and whenever I try to use getComponentByName() function i am getting undefined as a output . This is my code:

    import React, { useRef, useEffect } from “react”;
    import { JQXForm } from “jqwidgets-react/react_jqxform”;

    const MyForm = () => {
    const myFormRef = useRef(null);

    useEffect(() => {
    // Call getComponentByName after the form has been rendered
    if (myFormRef.current) {
    const submitButton = myFormRef.current.getComponentByName(“submitButton”);
    if (submitButton) {
    console.log(“Submit Button Component:”, submitButton);
    } else {
    console.error(“Submit Button not found!”);
    }
    }
    }, []);

    const template = [
    {
    type: “text”,
    name: “name”,
    label: “Name:”,
    labelPosition: “left”,
    },
    {
    type: “button”,
    name: “submitButton”,
    text: “Submit”,
    },
    ];

    return <JQXForm ref={myFormRef} template={template} />;
    };

    export default MyForm;

Viewing 1 post (of 1 total)