jeudi 30 juin 2022

Unable to set Checkbox to Checked after refreshing and storing in Local Storage

I am currently facing an issue where I am unable to set a input box to stay checked after a refresh. I have stored the values in the local storage, even though the value is stored in the local storage; the checkbox does not remain checked. Please do help me on this! Thank you

Here is the html code:

      <div style="color: #005e95">
        <input type="checkbox" id="checkboxFullDownload" data-dojo-attach-event="onClick: _test" style="cursor: pointer;"  >
        Full Download
      </div>

Here is the JS code:

_test: function(){
        let checkBox = document.getElementById("checkboxFullDownload")

        if(localStorage.getItem(`${xmlTitle} ID:${this.item._id}`) === "AllowFullDownload"){
          checkBox.setAttribute("checked",true)
          console.log("set to true")
        }

        if(checkBox.checked){
          console.log("Checked")
          localStorage.setItem(`${xmlTitle} ID:${this.item._id}`,"AllowFullDownload")
          checkBox.checked = true;
          }
  
        if(!checkBox.checked){
          console.log("Unchecked")
          localStorage.removeItem(`${xmlTitle} ID:${this.item._id}`)
          checkBox.setAttribute("checked",false)
          }
}



mercredi 29 juin 2022

function check from wxCheckListBox crash when it is called (wxwidgets)

I'm working on a application project for me with wxWidgets, and I encounter some troubles with the wxCheckListBox class. I am looking for a solution, and I saw that the check function worked well in the constructor function, but not in an event function. I have a check box "select all" who handle an event to select all check box of a list, here is my code

CheckListWindow::CheckListWindow(const wxString& name, const wxPoint& pos, const wxSize& size)
    : wxFrame(nullptr, wxID_ANY, name, pos, size)
{
    wxBoxSizer* m_sizer = new wxBoxSizer(wxHORIZONTAL);
    wxCheckListBox* m_checklist = new wxCheckListBox(this, wxID_ANY, wxPoint(20, 20), wxDefaultSize, g_vecPDF);

    wxCheckBox* m_selectall = new wxCheckBox(this, ID_CHECKBOX, wxString("Tout sélectionner"), wxPoint(10, wxDefaultPosition.y));
    m_checklist->Check(1, true); // work

    m_sizer->Add(m_selectall);
    m_sizer->Add(m_checklist);

    m_sizer->SetSizeHints(this);
}

void CheckListWindow::OnCheckBox(wxCommandEvent& evt)
{
    for (int index{ 0 }; index < static_cast<int>(g_vecPDF.size()); index++)
    {
        m_checklist->Check(index, true); // doesn't work
    }
    evt.Skip();
}

If I do that, the application crash when the event function is called. My question is, is there a way to modify the check box after his construction ?

Thank you!




Checkbox : Change root Styles

How can I change the root styles in Checkbox. This does not work.

 <CheckboxItem
                      onChange={()}
                      checked={isChecked}
                      label="Show Checkbox"
                      classes=
                    />
className=

is erroring out as well. Thank you.




mardi 28 juin 2022

Android - List View `CHOICE_MODE_SINGLE` not working

Thanks in advance to resolve this issue with android list view. This is the row of the list view adapter.

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="5dp"
        android:weightSum="13"
        android:orientation="horizontal"
        android:layout_marginStart="20dp">

        <CheckBox
            android:id="@+id/chkId"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1" />

        <TextView
            android:id="@+id/row_que_status"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"
            android:layout_marginRight="1dip"
            android:layout_weight="2"
            android:gravity="start"
            android:text="que_status"
            android:textAppearance="?android:attr/textAppearanceSmall" />

</LinearLayout>

And I have added the list view in fragment layout

    <ListView
       android:id="@+id/studentList"
       android:layout_height="match_parent"
       android:layout_width="match_parent"
       android:choiceMode="singleChoice">
    </ListView>

And also in my fragment I have set the mStudentListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); to disable the multiple selection of the list view.

But both options not working.




onChange Event not Triggered in React JS

export default function ActionRolesPage(props) {
      const [authorities, setAuthorities] = useState([]);
      const [name, setName] = useState("");
      let list = [];
      useEffect(() => {
        getAuthorities();
      }, []);
      const getAuthorities = () => {
        doGetAllAuthorities()
          .then((res) => {
            getValidatedData(res.data, "array").map((data) => (
              list.push({ authority: data})
            ))
            setAuthorities(list);
          }).catch((e) => {
            console.log(e);
          })
      }
      const handleChange = (e) => {
        console.log(e);
        const { name, checked } = e.target
        console.log(name,checked);
        let tempUser = authorities.map((user) => (
          user.authority === name ? { ...user, isChecked: checked } : user
        ));
        setAuthorities(tempUser);
      }
    
      if(authorities.length){
        console.log(authorities);
      }
    
      
      return (
        <React.Fragment>
          <Suspense fallback={<div>Loading....</div>}>
            <div className="page-content">
              <MetaTags>
                <title>Add Role | IG One</title>
              </MetaTags>
              <Container fluid>
                <Breadcrumb
                  title="Add Role"
                  breadcrumbItems={[{ title: "Settings" }, { title: "Roles" }, { title: "Add" }]}
                />
                <Form onSubmit={handleSubmit}>
                  <Card>
                    <CardBody>
                      <Row className="mb-3">
                        <label
                          htmlFor="example-text-input"
                          className="col-md-2 col-form-label"
                        >
                          Name
                        </label>
                        <div className="col-md-8 mx-0">
                          <Input
                            className="form-control"
                            type="text"
                            name="name"
                            required
                            value={name}
                            onChange={(e) => setName(e.target.value)}
                            placeholder="Name Of User "
                          />
                        </div>
                      </Row>
                      <br></br>
                      <br></br>
                      <Row className="mb-3">
                        <CardTitle>
                          Authorities
                        </CardTitle>
                        <div className="col-md-2">
    
                          {
                           
                              authorities.map((data,index) => (
                                <>
                                  <div key={index} style=>
                                    <div className='col-md-10 mx-0 mt-2'>
                                      <Input type={"checkbox"}
                                        checked={data?.isChecked || false}
                                        name={data.authority}
                                        onChange={(e) => console.log(e)}
                                        className="form-control"
                                        style=
                                      /></div>
                                    <div>
                                      <label style= htmlFor={data.authority} className="col-md-50 col-form-label"> {data.authority}</label>
                                    </div>
                                  </div>
                                </>
                              )) 
                          }
                        </div>
                      </Row>
                      <Row className="d-flex justify-content-center mt-4">
                        <Button color="dark" type='submit' className="btn-xs" style=
                        >
                          Add Role
                        </Button>
                      </Row>
                    </CardBody>
                  </Card>
                </Form>
              </Container>
            </div>
          </Suspense>
        </React.Fragment>
      )
    } 

Here is the whole code. I want to handle multiple checkboxes but onChange Event not triggered. There is a function handleChange it calls when onChange triggered but in my case there is no error seen in console as well as not display any event at console please resolve my doubt.

I also need to update the form getting respose from backend is checked authority name array How to handle checked state in checkbox.




WPF: set false as default for all checkbox controll

I have many checkbox binding nullable bool values and when I press on the control, if it's set to false, I have to press twice to get true. Is it possible to have true as the first value or false as default when I have null for all the checkbox, for example with a style?

I've tried with this before, and it works:

<CheckBox  IsThreeState="False" IsChecked="{Binding MY_NULLABLE_PROPERTY, TargetNullValue=false}"/>

but I would like a generic solution for each control




Required checkbox with custom label in WooCommerce product review form

Hi everyone! Nice to see so helpful community here.

Is there a way to add a required checkbox to WooCommerce product review form?

Thank you!