samedi 30 novembre 2019

Sort data by checking a checkbox with jquery?

I am getting data from an API and I want to sort it alphabetically when the checkbox is checked. But i am not sure where to put the code for this and to be honest i am not sure exactly what the code should be. I searched the internet but i cant make it work for my project. Please help. Here is my code. in the script i have started to write but probably is not right

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>MusicApp</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="main.css">
    <script src="https://code.jquery.com/jquery-3.4.1.js"></script>

</head>

<body>
    <header>
    <div class="container">
        <nav class="navbar navbar-inverse">
            <div class="container-fluid">
                <div class="navbar-header">
                    <a class="navbar-brand" href="#">MusicApp</a>
                </div>
                <ul class="nav navbar-nav">
                    <li><a href="#">Home</a></li>
                    <li><a href="#">About</a></li>
                    <li><a href="lyrics.html">Lyrics</a></li>
                </ul>
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
                    <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
                </ul>
            </div>
        </nav>
    </div>
</header>

<div class="container">
    <div class="row" style="margin-top:30px;">

        <div class="col-sm-4">

            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">Search</h3>
                </div>
                <div class="panel-body">
                    <div class="form-group">
                        <div class="row">
                            <div class="col-sm-4">
                                <img class="thumbnail img-responsive" src="images/notes.jpg">
                            </div>
                            <div class="col-sm-8">                            
                                <input type="checkbox" class="form-check-input" id="sort">
                                <label class="form-check-label" for="sort">Sort</label>                              
                            </div>

                        </div>

                        <div class="row">
                            <div class="col-sm-12">
                                <label for="artist">Artist:</label>
                                <input type="text" class="form-control" id="artist">
                            </div>
                        </div>

                    </div>
                </div>
                <div class="panel-footer" style="height:50px;">
                    <button type="button" id="searchBtn" class="btn btn-primary pull-right publish"><span
                            class="glyphicon glyphicon-globe"></span> Search
                    </button>
                </div>
            </div>
        </div>
        <div class="col-sm-8">

            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">Results</h3>
                </div>

                <ul class="list-group" style="min-height:241px;" id="contentList">

                    <li class="list-group-item" style="display:none" id="cloneMe">
                        <div class="row">
                            <div class="col-sm-2 col-xs-3">
                                <img src="images/notes.jpg" class="thumbnail img-responsive">
                            </div>
                            <div class="col-sm-7 col-xs-6">
                                <h4>Shakira</h4>
                                <p id="songName">some result </p>
                                <p id="lyricsLink">some result</p>
                            </div>
                            <div class="col-sm-3 col-xs-3">
                                <button type="button" class="btn btn-danger pull-right remove-post"><span
                                        class="glyphicon glyphicon-remove"></span><span class="hidden-xs"> Delete</span>
                                </button>
                            </div>
                        </div>
                    </li>

                </ul>
            </div>

        </div>
    </div>


</div>

</div>
</body>

<script>
    $(document).ready(function(){
    var api="1f57380a81msh394cf453f4d1e73p1a0276jsnab0cd43f0df7";

    $('#sort').click(function(){
      if($(this).is(':checked')){

      }

    });

    $('#searchBtn').click(function(){
        artistName=$('#artist').val();
        console.log(artistName);

        var settings = {
        "async": true,
        "crossDomain": true,
        "url": "https://genius.p.rapidapi.com/search?q=" + artistName,
        "method": "GET",
        "headers": {
            "x-rapidapi-host": "genius.p.rapidapi.com",
            "x-rapidapi-key": "1f57380a81msh394cf453f4d1e73p1a0276jsnab0cd43f0df7"
            }
        }


        $.ajax(settings)
        .done(function (response) {

           // console.log(response.response.hits);
          response.response.hits.forEach(r => {
            var miniMe = $('#cloneMe').clone();
                miniMe.attr('id', r.result.id);
            console.log(r.result.header_image_url);
                miniMe.find('img').attr('src', r.result.header_image_url);
                miniMe.find('h4').text(artistName);
                miniMe.find('#songName').html(r.result.full_title);
                miniMe.find('#lyricsLink').html(r.result.url);
                miniMe.find('button').click(function () {
                    miniMe.remove();
                });
                miniMe.find('checkbox').click(function(){

                })
                miniMe.show();
                $('#contentList').append(miniMe);
          });               
        });
        return false;
    });

});

</script>
</html>



Angular Material Editable Table with Checkboxes - Get only Arrayed Values

I created an Angular Material mat-table in my project that draws its datasource from an array, pulled from a webApi. All of that is working well. I am also using checkboxes to select the rows that I wish to grab and save. However, because I am using form fields and formGroup, can't figure out how to get only the data (value) I need when I invoke (this.selection.selected). See my screen grab.

I was not able to find anything online. I was trying to figure out how to get the formGroup's selected values, but it returns the entire datasource (I simply don't know how to get it). So, some guidance will be most welcome.

screen showing "this.selection.selected" array




How to precheck some checkbox in ReactJS

My code has many atributes that have to be choosed by user, he can choose 0 or all and sometimes some atributes will come checked if this user has been choose the atributes before, i've try hard to do this with reactjs but checked and defaultChecked props are confuse to me, here my code sample.

class App extends React.Component {
  state = {
    colors: [ 'red', 'black', 'green', 'blue', 'white', 'yellow' ],
    checkedColors: [ 'blue', 'yellow' ]
  }

  handleSubmit(e) {
    e.preventDefault()
    const { target } = e
    const formData = new FormData(target)
    const checkedColors = formData.getAll('colors')
    this.setState({ checkedColors })
  }
  
  render() {
  const { colors, checkedColors } = this.state
  return (
    <form onSubmit={this.handleSubmit.bind(this)}>
      <ul>
        {colors.map((color, index) => (
          <li key={index}>
            <input
              type='checkbox'
              name='colors'
              id={color}
              value={color}
              checked={checkedColors.some(chckColor => chckColor === color)}
            />
            <label htmlFor={color}>{color}</label>
           </li>
         ))}
        </ul>
        <button>submit</button>
        <span>{checkedColors.join(', ')}</span>
       </form>
     )
   }
}

ReactDOM.render(<App />, document.getElementById('root'))
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<div id="root"></div>



How to save checkbox item status in Checkedlistbox control in C# windows form application?

I have 2 Checkedlistbox controls in my C# windows form application program. First Checkedlistbox is for doctors' specialty for example dentist, radiologist and etc. If I check dentist checkbox doctors' specialty Checkedlistbox control, all doctors who are dentist will be shown in the doctors' name Checkedlistbox control.
The problem is that when I check dentist Checkedlistbox and then some dentists from doctors' Checkedlistbox, then if I check radiologist Checkedlistbox, then doctors' name Checkedlistbox will be reset and all my dentist checked checkbox will be de-selected.
What I have tried: Doctors' name Checkedlistbox data source:

DoctorsIDCheckedlistbox.DataSource = _ClinicEntities.Tbl_Doctors
      .Where(w => _SelectedSpecialty.Contains(w.SpecialtyID))
      .Select(s => new DoctorList { Name = s.Name + " " + s.LastName, DoctorID = s.DoctorID })
      .ToList();

DoctorsIDCheckedlistbox.DisplayMember = "Name";
DoctorsIDCheckedlistbox.ValueMember = "DoctorID";

Then I save checked items in ItemCheck event:

private void DoctorsID_ItemCheck(object sender, ItemCheckEventArgs e)
{
    int doctorID = Convert.ToInt32(DoctorsIDCheckedlistbox.SelectedValue);
    if (e.NewValue == CheckState.Checked)
    {
        _SelectedDoctorsChecked.Add(doctorID.ToString());
    }
    else
    {
        _SelectedDoctorsChecked.Remove(doctorID.ToString());
    }
}

Then for doctors' specialty ItemCheck event:

private void SpecialtyTypeID_ItemCheck(object sender, ItemCheckEventArgs e)
{
    for (int i = 0; i < DoctorsIDCheckedlistbox.Items.Count; i++)
    {
         if (_SelectedDoctorsChecked.Contains(DoctorsIDCheckedlistbox.Items[i].ToString()))
         {
             try
             {
                 DoctorsIDCheckedlistbox.SetItemChecked(i, true);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.ToString());
             }
        }
    }
}

I expect code above look through _SelectedDoctorsChecked list which is selected doctors and check them when doctors' specialty checkboxes status changes. But it don't work.

Example:
I check A in doctors' specialty and items 1, 2 and 3 will be shown in doctors' name. I check 1 and 3. When I check B in doctors' specialty, Items 1, 2 and 3 from A and 4, 5 and 6 from B will be shown. I expect number 1 and 3 be checked. But it won't.




vendredi 29 novembre 2019

how to get auto increment and decrement value of check box after submitting in flutter

Hi i am trying to display the check box value in the top of the page after submit the checkboxes.enter image description here

here if the gold value of one check box is 2 if we select 2 check boxes and submit it will show 4.




Save on localstorage appended checkbox state

I have this function:

function test() {
    var a = document.getElementById('test');
    var b = document.createElement('input');
    b.type = 'checkbox';
    b.addEventListener( 'change', function() {
    if(this.checked) {
       //do something and save the state (checked)
    } else {
       //do something else and save the state(not checked)
    }
}

and I want to save the state of the checkbox on localstorage from the appended checkbox, what is the best way to do it?




Python way around 128 if statements

I have a tkinter application I am working on which has button which when pressed fires a function. I also have about 7 checkboxs which when checked changes its own variable from 0 to 1.

In the function I have a bunch of if statements that goes through every combination of the checkboxes and performs and action. The issue is because the checkbox can have two states, off (0) and on (1) with 7 checkboxes - if we do 2 to the power of 7 to work out every single combination, that is 128 if statements I will need to write out.

I have also thought about writing 7 if statement to check each state of each checkbox then moving onto the next one but because I need to loop through a 2 lists and perform different actions, it's hard to log what is happening at each stage without duplication of logs or the detail I need.

Is there a better way of doing this?

Any help would be great, thanks!




How to create CheckBox automatically using PowerShell?

I want to create checkbox automatically consider to the total a file inside a folder I selected. In my script, the checkbox always create one checkbox, but my file more than one. And the checkbox always appear before I select the folder from listbox. Please give me advice if anyone know about this, Thank you so much. This is the result look like

enter image description here

$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = "Select a Computer"
$objForm.Size = New-Object System.Drawing.Size(500,700)
$objForm.StartPosition = "CenterScreen"
$objForm.Text = "Test"
$objListBox = New-Object System.Windows.Forms.ListBox
$objListBox.Location = New-Object System.Drawing.Size(10,70)
$objListBox.Size = New-Object System.Drawing.Size(260,30)
$objListBox.Height = 250
$objListBox.add_SelectedIndexChanged($SelectedFile)
$objForm.Controls.Add($objListBox)

$objChktBox = New-Object System.Windows.Forms.CheckBox
$objChktBox.Location = New-Object System.Drawing.Size(10,400)
$objChktBox.Size = New-Object System.Drawing.Size(400,3000)
$objChktBox.Height = 200
$objForm.Controls.Add($objChktBox)
# Populate list.
@(Get-ChildItem -Directory ".\").Name | ForEach-Object {[void] $objListBox.Items.Add($_)}
$SelectedFile= 
{
$objChktBox.Text = (Get-ChildItem $objListbox.SelectedItem)
}
$objForm.ShowDialog()



TCheckBox that autoresize (like TLabel)

I want to create a checkbox that can automatically resize its width, exactly like TLabel. But I have a problem. The checkboxes placed in non-active tabs of a PageControl won't automatically recompute their size. In other words, if I have two tabs that contain custom checkbox, at aplication start up only the checkbox in the current open tab will be correctly resized. When I click the other tab, the checks will have the original width (the one set at design time).

UNIT cvCheckBox;

{--------------------------------------------------------------------------------------------------
  A checkbox that autoresizes exactly like TLabel
  It incercepts CMTextChanged where it recomputes the new Width

  Features:
      + Autoresize width to fix the text inside
      + property AutoSize;

--------------------------------------------------------------------------------------------------}

INTERFACE

{$DEBUGINFO ON}
{$WARN GARBAGE OFF}                                                                                           {Silence the: 'W1011 Text after final END' warning }

USES
  Winapi.Windows, Winapi.Messages, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.StdCtrls;

TYPE
 TcCheckBox = class(TCheckBox)
 private
   FAutoSize: Boolean;
   procedure AdjustBounds;
   procedure setAutoSize(b: Boolean);  reintroduce;
   procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
   procedure CMTextChanged(var Message: TMessage); message CM_TEXTCHANGED;
 protected
    procedure Loaded; override;
 public
    constructor Create(AOwner: TComponent); override;
 published
    //property Caption read GetText write SetText;
    property AutoSize: Boolean read FAutoSize write setAutoSize stored TRUE;
 end;


procedure Register;

IMPLEMENTATION

CONST
  SysCheckWidth: Integer = 21;  // In theory this can be obtained from the "system"



constructor TcCheckBox.Create(AOwner : TComponent);
begin
  inherited Create(AOwner);
  FAutoSize:= TRUE;
end;


procedure TcCheckBox.AdjustBounds;
VAR
   DC: HDC;
   Canvas: TCanvas;
begin
  if not (csReading in ComponentState) and FAutoSize then
  begin
    if HandleAllocated then  // Deals with the missing parent during Creation
    begin
     // We need a canvas but this control has none. So we need to "produce" one.
     Canvas := TCanvas.Create;
     DC     := GetDC(Handle);
     TRY
       Canvas.Handle := DC;
       Canvas.Font   := Font;
       Width := Canvas.TextWidth(Caption) + SysCheckWidth + 4;
       Canvas.Handle := 0;
     FINALLY
       ReleaseDC(Handle, DC);
       Canvas.Free;
     END;
    end;
  end;
end;


procedure TcCheckBox.setAutoSize(b: Boolean);
begin
  if FAutoSize <> b then
  begin
    FAutoSize := b;
    if b then AdjustBounds;
  end;
end;

procedure TcCheckBox.CMTextChanged(var Message:TMessage);
begin
  Invalidate;
  AdjustBounds;
end;


procedure TcCheckBox.CMFontChanged(var Message:TMessage);
begin
  inherited;
  if AutoSize
  then AdjustBounds;
end;

procedure TcCheckBox.Loaded;
begin
  inherited Loaded;
  AdjustBounds;
end;


procedure Register;
begin
  RegisterComponents('test', [TcCheckBox]);
end;


{
procedure TcCheckBox.SetText(const Value: TCaption);
begin
  if GetText <> Value then
  begin
    SetTextBuf(PChar(Value));
    if FAutoSize then AdjustBounds;
  end;
end;

function TcCheckBox.GetText: TCaption;
var
  Len: Integer;
begin
  Len := GetTextLen;
  SetString(Result, PChar(nil), Len);
  if Len <> 0 then GetTextBuf(Pointer(Result), Len + 1);
end;  }
end.

I do set the size of the font for the entire form at program startup (after Form Create, with PostMessage(Self.Handle, MSG_LateInitialize) ).
Why my checkbox is not announced that the font has changed?

procedure TForm5.FormCreate(Sender: TObject);
begin
 PostMessage(Self.Handle, MSG_LateInitialize, 0, 0);  
end;

procedure TForm5.LateInitialize(var message: TMessage);
begin
 Font:= 22;
end;



JavaFX sorting tableview - issues using comparator and updating the tableview to the sorted list

I'm experiencing a lot of errors trying to sort my TableView in JavaFX. The view consists of the table, and two check boxes, sorting a view by status (alphabetical) and a referralDate (numeric).

public class ReferralListCtrl implements Initializable {

    @FXML
    private TableView<ReferralListModel> referralListTable;
    @FXML
    private TableColumn<ReferralListModel, String> recievedDateColumn;
    @FXML
    private TableColumn<ReferralListModel, String> referredDateColumn;
    @FXML
    private TableColumn<ReferralListModel, String> layDaysColumn;
    @FXML
    private TableColumn<ReferralListModel, String> statusColumn;
    @FXML
    private TableColumn<ReferralListModel, String> assignedColumn;
    @FXML
    private TableColumn<ReferralListModel, String> referredFromColumn;
    @FXML
    private TableColumn<ReferralListModel, String> patientColumn;
    @FXML
    private TableColumn<ReferralListModel, String> referralCauseColumn;
    @FXML
    private TableColumn<ReferralListModel, String> referralIDColumn;
    @FXML
    private TableColumn<ReferralListModel, String> referralTypeColumn;
    @FXML
    private CheckBox sortByDateBtn;
    @FXML
    private CheckBox sortByStatusBtn;
    @FXML
    private Label searchLabelTest;
    @FXML
    private HBox sortHBox;

    //If button is pressed
    @FXML
    public void searchButtonPressed(){

            String sortLabel = "Valgte sortering:";
            if (sortByDateBtn.isSelected()){
                //control to see if buttons is detectable
                sortLabel += "\nDato";
            }

            if (sortByStatusBtn.isSelected()){
                SortedList<String> mySortedList = new SortedList(getReferralListData());
                mySortedList.setComparator(new Comparator<ReferralListModel>(){
                    @Override
                    public int compare(ReferralListModel o1, ReferralListModel o2) {
                        //Two methods of comparing I have tried
                        return o1.compareToIgnoreCase(o2);
                        //return o1.getStatus().compareToIgnoreCase(o2.getStatus());
                    }
                });
                //updating the list
                referralListTable.setItems(referralListData.sorted());

                sortLabel += "\nstatus";
            }

        this.searchLabelTest.setText(sortLabel);
    } 

    // Reference to the main application.
    private MainApp mainApp;

    /***
     * The constructor. The constructor is called before the initialize() method.
     */
    public ReferralListCtrl() {
    }

    //defining new lists that is sorted
private SortedList mySortedList;
private ObservableList<Comparator<ReferralListModel>> listComparators;
ObservableList<ReferralListModel> referralListData = FXCollections.observableArrayList();


/**
 * Returns the data as an observable list of the referrals.
 * 
 * @return
 */
public ObservableList<ReferralListModel> getReferralListData() {
   return referralListData;
}



    @Override
    public void initialize(URL location, ResourceBundle resources) {
        recievedDateColumn.setCellValueFactory(new PropertyValueFactory<ReferralListModel, String>("recievedDate"));
        referredDateColumn.setCellValueFactory(new PropertyValueFactory<ReferralListModel, String>("referredDate"));
        layDaysColumn.setCellValueFactory(new PropertyValueFactory<ReferralListModel, String>("layDays"));
        statusColumn.setCellValueFactory(new PropertyValueFactory<ReferralListModel, String>("status"));
        assignedColumn.setCellValueFactory(new PropertyValueFactory<ReferralListModel, String>("assigned"));
        referredFromColumn.setCellValueFactory(new PropertyValueFactory<ReferralListModel, String>("referredFrom"));
        patientColumn.setCellValueFactory(new PropertyValueFactory<ReferralListModel, String>("patient"));
        referralCauseColumn.setCellValueFactory(new PropertyValueFactory<ReferralListModel, String>("referralCause"));
        referralIDColumn.setCellValueFactory(new PropertyValueFactory<ReferralListModel, String>("referralID"));
        referralTypeColumn.setCellValueFactory(new PropertyValueFactory<ReferralListModel, String>("referralType"));

        referralListData.add(new ReferralListModel("1/1-2019", "1/12-2019", "30", "Modtaget", "Alle", "Laegehus A",
        "Hans 233492-1233", "Aarsag 1", "ICPC-kode", "A"));
referralListData.add(new ReferralListModel("12/1-2019", "12/1-2019", "0", "Visiteret", "Alle", "Laegehus B",
        "Ruth 290506-1236", "Aarsag 1", "ICD10-kode", "B"));
referralListData.add(new ReferralListModel("2/1-2019", "2/1-2019", "29", "Modtaget", "Alle", "Laegehus C",
        "Heinz 311200-9561", "Aarsag 1", "ICPC-kode", "C"));
referralListData.add(new ReferralListModel("4/1-2019", "1/1-2019", "27", "Modtaget", "Alle", "Laegehus D",
        "Cornelia 290483-2096", "Aarsag 1", "ICPC-kode", "D"));
referralListData.add(new ReferralListModel("7/1-2019", "6/1-2019", "24", "Modtaget", "Alle", "Laegehus E",
        "Werner 192835-1023", "Aarsag 1", "ICPC-kode", "E"));
referralListData.add(new ReferralListModel("20/1-2019", "19/1-2019", "0", "Visiteret", "Alle", "Laegehus F",
        "Lydia 101039-5302", "Aarsag 1", "ICD10-kode", "F"));

        referralListTable.setItems(getReferralListData());
    }

How do I modify the comparator so that it will sort alphabeticly and numericly?

How to I update the tableview to the sorted list?




jeudi 28 novembre 2019

How to change status of the Flutter gridview.count checkbox list?

I generated a list of checkbox using flutter gridview.count. Now I want to separately change the status of each checkbox.

Can you please tell me how to change the value of the checkbox

Grid view

child: new GridView.count(
                            crossAxisCount: 2,
                            shrinkWrap: true,
                            childAspectRatio: 8.0,
                            children:
                                List.generate(pllistdata.length, (index) {
                              return Pldata(pllistdata[index], index);
                            }),
                          ),

returned Widget

Card Pldata(String plname, int id) {
return Card(
  child: Padding(
    padding: const EdgeInsets.all(10.0),
    child: new Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: <Widget>[
        Text(
          '$plname',
          style: TextStyle(
              fontWeight: FontWeight.bold,
              color: Colors.black54,
              fontSize: 16.0),
        ),
        CircularCheckBox(
          value: pl_status,
          materialTapTargetSize: MaterialTapTargetSize.padded,
          onChanged: (x) {
            setState(() {
            prefs.setStringList('PL', sflist);
            });
          },
          activeColor: Colors.red[800],
          inactiveColor: Colors.grey,
        )
      ],
    ),
  ),
);

}




React Update Fetch on Checkbox Click

I have a component(Card) that has checkboxes that are tracked in a localhost database using Postgres. When I check or uncheck the box, an entry gets put into the networkusers table. The problem is that when I check or uncheck the box, and then click on a button to render a different component and then come back to the Card component with the checkboxes, the boxes are not showing the updated check. However, if I sign out and sign back in, all the boxes are updated and in sync with database. So how do I get the component to render (or fetch again?) as soon as checkbox is changed in the following component? TY.

import React, { useState } from "react";

const onUpdateCB = (ischecked, loginuser, userid, setisChecked,handleCheck,event) => {

  console.log(ischecked, loginuser, userid);

  fetch('http://localhost:3000/cb', {
      method: 'post',
      headers: {'Content-Type':'application/json'},
      body:JSON.stringify({
      loginuser,
      userid,
      ischecked: ischecked
    })
  }).then(setisChecked(ischecked)); 
};

const Card = props => {
  const [isChecked, setisChecked] = useState(props.ischecked);
  return (
    <div
      className="pointer bg-light-green dib br3 pa3 ma2 shadow-5"
      onClick={() => props.handleClick(props.id)}
      //onClick={(e) => e.stopPropagation()}

    >
      <div>
        <h3>{props.name}</h3>
        <p>{props.company}</p>
        <p>{props.phone}</p>
        <p>{props.email}</p>
        <p>{props.city}</p>
      </div>
      <div>
        My Network
        <input
          className="largeCheckbox"
          type="checkbox"
          checked={isChecked}
          onClick={(event) =>
            onUpdateCB(!isChecked, props.loginuser.id, props.id, setisChecked,event.stopPropagation())
          }
        />
      </div>
    </div>
  );
};

export default Card;



Checkbox uncheck - Laravel

I have to add checkbox to my datatable in Laravel but when I want to uncheck and remove selected item I can't do it.

My postings controller:

 return Datatables\DataTables::of($postings)
             ->addColumn('checkbox', function ($posting) {
                 return "<a href='#!' onclick='addToFavorites(" . $posting->id . ")'><i class=\"posting-id \"></i></button>
                          <input type='checkbox' class='posting-id' value='checked" . $posting-id . "'>";
 // onclick=\"removeFromFavorites(" + value['id'] + ")



Checkbox behave like radiobox javascript

I have a table that is dynamically created based on a number that is selected by a user from a dropdown. The table consists of 3 checkboxes. The maximum number of checkboxes that can be checked per row is 2.

Checkbox 2 and 3 behave like radio buttons (I know it would make my life easier to use just radio buttons but then the table doesn't look right as there is one checkbox and 2 radio buttons). If 2 is selected and then the user clicks on 3, then 2 would become unchecked.

I found this script here: http://jsfiddle.net/44Zfv/724/ which works perfectly but when I try to integrate it into my project it doesn't work.

I have created a fiddle here: https://jsfiddle.net/pcqravwj/1/ This demonstates the scenario. As you will see the checkboxes on row 0 are not dynamically created and both checkboxes cannot be checked. I have added the class .cbh to my dynamically created checkboxes on row 1. However, all 3 checkboxes can be checked but I do notice that if a checkbox in row 0 is checked it clears the checkboxes which have the same class in row 1.

This is the piece of code I am using to try and control the checkbox behavouir

            $(".chb").prop('checked', false);
            $(this).prop('checked', true);
            console.log("test3")
        });

I just wondered if anyone could help me figure out what is happening here. As a newbie, the script looks like it should work and I am struggling to find the mistake.

Your help would be greatly appreciated.

Thanks!




insert multiple rows with checkboxes into table

I have a number of rows with some checkboxes and I want for each row some value to be inserted into a table.

E.g. if the checkbox 'more_than_45min' is checked, the value 4 must be inserted into that row of that player, if the checkbox 'less_than_45min' is checked, the value 2 must be inserted into that row of that player.

The checkboxes can't be choose both but can be both empty (if a player hasn't played at all)

$query  = "SELECT * FROM players WHERE club = 'AJA'";
if ($result = mysqli_query($conn, $query)) {
  while ($row = mysqli_fetch_assoc($result)) {
    $name       = $row["name"];
    $player_id  = $row["player_id"];
    echo "<div class='row pt-2'>";
      echo "<div class='col-md-4'>" . $name . "</div>";
      echo "<div class='col-md-1'><input class='custom-control-input' type='checkbox' data-speler-id=" . $player_id ." id='more_than_45min_" . $player_id ."'></div>";
      echo "<div class='col-md-1'><input class='custom-control-input' type='checkbox' data-speler-id=" . $player_id ." id='less_than_45min_" . $player_id ."'></div>";
    echo "</div>";
  }
}

I have added an hidden field to check if the form has been submitted so I can insert the values into the table 'players_points', the fields in this table are:

  • id (AI)
  • player_id
  • more_than_45min
  • less_than_45min

Here's the start for the insert into the table.

if(isset($_POST['player_points_submit'])) {
  // here the insert
}

I know how to insert the data into the table but how to loop through all the rows and submitted 4 or 2 into the table if a checkbox is checked?

Kind regards,

Arie




mat-checkbox - how to get value from disabled checkbox

I need help in getting the value of disabled checkbox. I have two level of users, so for admins, checkbox should be available and for regulars users disabled. I have that case solved, but I have a problem when regular user submit the form, because value of "isActive" is undefined. Thats because its disabled... After some googling, I tried adding another input which is hidden, but thats not working too...

    <mat-checkbox class="mr-3" color="primary" [checked]="user.isActive" name="isActive" [ngModel]="user.isActive" [disabled]="!isAdmin">
        Active
    </mat-checkbox>

    <mat-checkbox hidden="true" name="isActive" [(ngModel)]="user.isActive"></mat-checkbox>



How to control the state of multiple checkboxes in child component by the parent in react?

I have multiple check-boxes which are dynamic. These check boxes are placed (assume) in "B" component. I have managed the state of these check boxes in "A" component which is the parent of "B". When one or all the check boxes are clicked I want to render a div

expected result : render div if one or all the check boxes are clicked. If none is selected the div should be hidden. Basically the div should be visible even if a single checkbox is checked.

current result : When one check box is clicked the the div gets rendered but if another checkbox is selected the div disappears.

Here's my A component (Parent)

const A = () => {
   const [isChecked, setIsChecked] = useState(false) // state that holds state of check boxes 

   return (
      {isChecked ? <div>Some Content..</div> : null} // rendering the div according to the state of the checkboxes

      <Child isChecked={isChecked} setIsChecked={setIsChecked} />
  ) 
}

Code of Child Component

 const Child = props => {

        return (
           {checkBoxList.map((box, index) => (
              <CustomCheckBox
                 key={index}
                 name={`check-box-${index}`}  // to uniquely identify each check box 
                 isChecked={props.isChecked}
                 setIsChecked={props.setIsChecked} />
           ))}
        )
    }

CustomCheckBox component :

 const CustomCheckBox = props => {

      const onChangeHandler = (event) => {
         props.isChecked ? props.setIsChecked(false) : props.setIsChecked(true)
      }

      return <input name={props.name} type="checkBox" onChange={onChangeHandler} />;
 };

  CustomCheckBox.propTypes = {
    name: string
  }

I'm aware that the parent component state is only capable of handling a single check box right now.

The reason for the current result is because of the condition that I have included onChangeHandler function.

  props.isChecked ? props.setIsChecked(false) : props.setIsChecked(true)

I'm confused about how to handle the state of multiple check boxes in the above stated scenario using a single handler function !




How to create check box automatically depends on folder selected using PowerShell?

I need to create a checkbox automatically depends on folder I selected. I create ComboBox, then in the ComboBox, I can select which folder that I want to select. Inside of my folder, I have some file. The file consist of some extension file. I just need to pick 2 extension file from the folder, example(*.txt and *.csv).

After I select the folder, the checkBox will create automatically, the total of the checkBox depends on how many file exist in that folder with specific extension(*.txt and *.csv).

In my code, I already do some stuff, which is select the folder that I need to select, but still struggle with the checkBox. Anyone can help me please. Thank you so much. I really appreciate for the help.

Add-Type -AssemblyName PresentationFramework
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()

# $Global:status = "inactive" 
# $Global:array = New-Object System.Collections.Generic.List[System.Object]

$Form                            = New-Object system.Windows.Forms.Form
$Form.BackColor                  = "#f6f6f6"
$Form.AutoSize                   = $true
$Form.FormBorderStyle            = "FixedDialog"
$Form.MaximizeBox                = $false
$Form.startposition              = "centerscreen"
$Form.WindowState                = 'Maximized'

$Label1                          = New-Object system.Windows.Forms.Label
$Label1.text                     = "FOLDER"
$Label1.AutoSize                 = $true
$Label1.width                    = 25
$Label1.height                   = 10
$Label1.location                 = New-Object System.Drawing.Point(35,80)
$Label1.Font                     = 'Microsoft Sans Serif,12,style=Bold'
$Label1.ForeColor                = "#000000"

$Button3                         = New-Object system.Windows.Forms.Button
$Button3.BackColor               = "#136aa4"
$Button3.ForeColor               = "#ffffff"
$Button3.text                    = "Done"
$Button3.width                   = 90
$Button3.height                  = 32
$Button3.UseCompatibleTextRendering = $True
$Button3.location                = New-Object System.Drawing.Point(1700,920)
$Button3.Font                    = 'Microsoft Sans Serif,10'
$Button3.Visible                 = $false

$Button2                         = New-Object system.Windows.Forms.Button
$Button2.BackColor               = "#136aa4"
$Button2.ForeColor               = "#ffffff"
$Button2.text                    = "Delete"
$Button2.width                   = 90
$Button2.height                  = 32
$Button2.UseCompatibleTextRendering = $True
$Button2.location                = New-Object System.Drawing.Point(1600,920)
$Button2.Font                    = 'Microsoft Sans Serif,10'
$Button2.Visible                 = $false

$Panel = New-Object System.Windows.Forms.TableLayoutPanel
$panel.Dock = "Fill"
$panel.ColumnCount = 1
$panel.RowCount = 1
$panel.CellBorderStyle = "single"
$panel.ColumnStyles.Add((new-object System.Windows.Forms.ColumnStyle([System.Windows.Forms.SizeType]::Percent, 100)))
$panel.RowStyles.Add((new-object System.Windows.Forms.RowStyle([System.Windows.Forms.SizeType]::Percent, 100)))


$Groupbox1                       = New-Object system.Windows.Forms.Groupbox
$Groupbox1.text                  = "Handling"
$Groupbox1.Font                  = 'Microsoft Sans Serif,9'
$Groupbox1.AutoSize              = $true
$Groupbox1.ForeColor             = "#032d5d"
$Groupbox1.location              = New-Object System.Drawing.Point(8,13)
$Groupbox1.Padding               = New-Object -TypeName System.Windows.Forms.Padding -ArgumentList (0,5,5,0)
$Groupbox1.Dock                  = "fill"

$Groupbox2                       = New-Object system.Windows.Forms.Groupbox
$Groupbox2.text                  = "Information"
$Groupbox2.Font                  = 'Microsoft Sans Serif,9'
$Groupbox2.AutoSize              = $true
$Groupbox2.ForeColor             = "#032d5d"
$Groupbox2.Dock                  = "None"

$Groupbox1.Height
$Groupbox1.Width
$g2w = $Groupbox1.Width * 9.2
$g2h = $Groupbox1.Height * 7

$Groupbox2.location              = New-Object System.Drawing.Point(35,203)
$Groupbox2.size                  = New-Object System.Drawing.Size($g2w,$g2h)


$ComboBox1                        = New-Object system.Windows.Forms.ComboBox
$ComboBox1.BackColor              = "#e8f3ff"
$ComboBox1.width                  = 180
$ComboBox1.height                 = 20
$ComboBox1.location               = New-Object System.Drawing.Point(100,75)
$ComboBox1.Font                   = 'Microsoft Sans Serif,12'
$ComboBox1.AutoSize               = $true
$ImageList = @(Get-ChildItem -Directory "D:\Process")
foreach ($img in $ImageList) {
    $ComboBox1.Items.Add($img)
}


$Form.controls.AddRange(@($Panel))
$Panel.controls.AddRange(@($Groupbox1))
$Groupbox1.Controls.AddRange(@($Groupbox2, $ComboBox1, $Label1, $Button3, $Button2))

[void]$Form.ShowDialog()



mercredi 27 novembre 2019

Store lots of checkboxes in SQL / C#

Hello Community from a C# Newbie;

i dont find anything like this here with the search function so ill hope its not a stupid question . ( And sorry for my bad english ) .

ive planned to do a checklist with many checkboxes inside (over 30 ill guess), im now thinking about how to store the status ( check or not checked ) into my SQL Database and read it out .

Plan A : For each Checkbox ill do a Column in my Database wich sound like an easy way but i think there has to be a better way in sense of Performance

Plan B : like an binary code in a single Column - like 00100 - means that just the 3rd Checkbox is a checked Checkbox . Makes more sense to me but give me a little bit the feeling that it is hard to code especially in case of reading those checkbox list out from SQL again like


if (00100 == 00010) checkbox2.checked;
if (00100 == 00100) checkbox3.checked;

Ill hope u can help a C# Newbie and give me maybe some other Solutions Ideas.

Thank you All Greetings from Austria




How to change an event of a checkbox?

i am getting data from an api using ajax request and i want to sort the data that i am taking from an api alphabetically if the checkbox is checked. I am not sure exactly what and where to write. I am giving you my code. I know there are a lot of examples but i cant make it work for mine. Please help me figure it out!

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>MusicApp</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">

    <script src="https://code.jquery.com/jquery-3.4.1.js"></script>

</head>

<body>
    <header>
    <div class="container">
        <nav class="navbar navbar-inverse">
            <div class="container-fluid">
                <div class="navbar-header">
                    <a class="navbar-brand" href="index.html">MusicApp</a>
                </div>
                <ul class="nav navbar-nav">
                    <li class="active"><a href="index.html">Home</a></li>
                    <li><a href="#">About</a></li>
                    <li><a href="#">Lyrics</a></li>
                </ul>
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
                    <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
                </ul>
            </div>
        </nav>
    </div>
</header>

<div class="container">
    <div class="row" style="margin-top:30px;">

        <div class="col-sm-4">

            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">Search</h3>
                </div>
                <div class="panel-body">
                    <div class="form-group">
                        <div class="row">
                            <div class="col-sm-4">
                                <img class="thumbnail img-responsive" src="images/notes.jpg">
                            </div>
                            <div class="col-sm-8">                            
                                <input type="checkbox" class="form-check-input" id="sort">
                                <label class="form-check-label" for="sort">Sort</label>                              
                            </div>

                        </div>

                        <div class="row">
                            <div class="col-sm-12">
                                <label for="artist">Artist:</label>
                                <textarea class="form-control" rows="1" id="artist"></textarea>
                            </div>
                        </div>

                    </div>
                </div>
                <div class="panel-footer" style="height:55px;">
                    <button type="button" id="postComment" class="btn btn-primary pull-right publish"><span
                            class="glyphicon glyphicon-globe"></span> Search
                    </button>
                </div>
            </div>
        </div>
        <div class="col-sm-8">

            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">Results</h3>
                </div>

                <ul class="list-group" style="min-height:241px;" id="contentList">

                    <li class="list-group-item" style="display:none" id="cloneMe">
                        <div class="row">
                            <div class="col-sm-2 col-xs-3">
                                <img src="images/notes.jpg" class="thumbnail img-responsive">
                            </div>
                            <div class="col-sm-7 col-xs-6">
                                <h4>Shakira</h4>
                                <p id="songName">some result </p>
                                <p id="lyricsLink">some result</p>
                            </div>
                            <div class="col-sm-3 col-xs-3">
                                <button type="button" class="btn btn-danger pull-right remove-post"><span
                                        class="glyphicon glyphicon-remove"></span><span class="hidden-xs"> Delete</span>
                                </button>
                            </div>
                        </div>
                    </li>

                </ul>
            </div>

        </div>
    </div>


</div>

</div>
</body>

<script>
    $(document).ready(function(){
    var api="1f57380a81msh394cf453f4d1e73p1a0276jsnab0cd43f0df7";

    $('#postComment').click(function(){
        artistName=$('#artist').val();
        console.log(artistName);

        var settings = {
        "async": true,
        "crossDomain": true,
        "url": "https://genius.p.rapidapi.com/search?q=" + artistName,
        "method": "GET",
        "headers": {
            "x-rapidapi-host": "genius.p.rapidapi.com",
            "x-rapidapi-key": "1f57380a81msh394cf453f4d1e73p1a0276jsnab0cd43f0df7"
            }
        }

        $.ajax(settings)
        .done(function (response) {
            console.log(response.response.hits);
          response.response.hits.forEach(r => {
            var miniMe = $('#cloneMe').clone();
                miniMe.attr('id', r.result.id);
            console.log(r.result.header_image_url);
                miniMe.find('img').attr('src', r.result.header_image_url);
                miniMe.find('h4').text(artistName);
                miniMe.find('#songName').html(r.result.full_title);
                miniMe.find('#lyricsLink').html(r.result.url);
                miniMe.find('button').click(function () {
                    miniMe.remove();
                });
                miniMe.find('checkbox').click(function(){

                })
                miniMe.show();
                $('#contentList').append(miniMe);
          });               
        });
        return false;
    });

});

</script>
</html>



Keep checkbox state across pagination vue-bootstrap

I am using a bootstrap table using pagination to display users. On every row a checkbox for selecting more than one at a time to perform an action. I manage to write the functions to select one and select all, keeping the array across pagination. But now I am not able to control the ui while navigating across pages using pagination. As I said, the array I created for storing the selected users stays across pages, but I 'loose the tick' on the checkboxes... It looks like the v-model binding gets lost while surfing the pages... Here the inherent parts of the code, hoping someone could help. In the template:

<b-table
            v-if="users && users.length > 0 && !isLoading"
            id="table-transition-userList"
            :key="users.id"
            responsive
            :tbody-transition-props="transProps"
            :fields="fields"
            :items="users"
            hover
            class="mx-2 py-1 tbl-user-list"
            :per-page="perPage"
            :filter="filter"
            :filterIncludedFields="filterOn"
            @filtered="onFiltered"
          > 
          <template
            v-slot:head(checkbox)="data">
            <b-form-checkbox
              size="lg"
              v-model="isSelectedAll"
              @change="selectAll(data)"
            />
          </template>
          <template
            v-slot:cell(checkbox)="data"
          >
            <b-form-checkbox
              v-model="data.item.selected"
              @change="select(data.item)"
            />
          </template>

In the script data:

fields: [
        { key: 'checkbox', label: ''},
        { key: 'fullName', label: 'Utente' },
        { key: 'user.username', label: 'Username' },
        { key: 'user.email', label: 'Email' },
        { key: 'buttons', label: 'Operazioni' }
      ],
      totalRows: 1,
      currentPage: 1,
      perPage: 5,
      pageOptions: [5, 10, 15, 20, 25],
      filter: null,
      filterOn: [],
      users: [],
      selectedUsers: [],
      isSelectedAll: false

In the methods:

selectAll() {
      this.isSelectedAll = !this.isSelectedAll
      this.users.forEach(user => user.selected = this.isSelectedAll)

      const notSelected = this.users.filter(user => !user.selected)
      const selected = this.users.filter(user => user.selected)

      // new selected users array without current page selected users
      let selectedUsersCopy = this.selectedUsers.slice().filter(user =>
        !notSelected.find(e => e.id === user.id)
      )
      if(notSelected.length > 0) {
        this.isSelectedAll = true
      }
      else {
        this.isSelectedAll = false
      }
      this.selectedUsers = [
        ...selectedUsersCopy,
        ...selected.filter(user => !selectedUsersCopy.find(e => e.id === user.id))
      ];

      console.log('selected', selected, 'this.sele', this.selectedUsers, 'copy', selectedUsersCopy, 'notSele', notSelected)
    },
    select(user) {
      user.selected = !user.selected
      this.isSelectedAll = false
      const selected = this.users.filter(user => user.selected)
      if(selected.length === this.users.length) {
        this.isSelectedAll = true
      }
      else {
        this.isSelectedAll = false
      }
      let isDouble = false
      if(this.selectedUsers.find(v => v.user.id === user.id)) isDouble = true
      if(user.selected) {
        if(isDouble) {
          console.log('double if user selected and isDouble', isDouble)
          console.log("object already exists", this.selectedUsers)
          return
        }
        else {
          this.selectedUsers.push(user)
          console.log("pushed", this.selectedUsers)
          return this.selectedUsers
        }
      }
      else {
        const index = this.selectedUsers.indexOf(user);
        this.selectedUsers.splice(index, 1);
        console.log("removed, new array: ", this.selectedUsers)
      }
    },
    async pagination(page) {
      const payload = {
        limit: this.perPage,
        offset: (page - 1) * this.perPage
      }
      this.isLoading = true
      this.isSelectedAll = false
      await this.$store.dispatch('user/setUsers', payload)
      const response = this.$store.getters.users
      this.users = response.results
      this.isLoading = false
      this.currentPage = page
    }

My pagination is calling different apis with different limits and offsets. I think the problem is to be found in the built-in checked property of the form checkbox though... Thanks to anyone who could give me a hint. xx




Group Checkboxes on Submit

I have a form like this

<form action=''>
<label for="carrot">Carrot Collection</label><input type="checkbox" id="carrot" name="skills" value="carrot"><br>
<label for="potato">Potato Collection</label><input type="checkbox" id="potato" name="skills" value="potato"><br>
<button type='submit'>Neu Laden</button><br>

When I press the Button i currently get:

foo.bar/test.html?skills=carrot&skills=potato

Is there an easy way to achieve something like foo.bar/test.html?skills=carrot,potato
There will be an awful lot of Checkboxes and it would be quite a pain to query all of them to build the Request string.




CheckBox in DataGrid

Hi I create this code for understand why if put a checkbox out to datagrid all work but if insert a checkbox into datagrid don't work.

This run correct:

      <CheckBox x:Name="checkBox" Content="Test" Margin="0" Command="{Binding SelectCommand}" CommandParameter="{Binding IsChecked, RelativeSource={RelativeSource Self}}"/>

But this not:

<DataGrid x:Name="dataGrid" ItemsSource="{Binding XMLValue}" >
        <DataGrid.Columns>
            <DataGridTemplateColumn>
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <CheckBox x:Name="TestCheckBox" Command="{Binding Path=SelectCommand, RelativeSource={RelativeSource FindAncestor, AncestorType=DataGrid}}"  IsChecked="{Binding Path=Selected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
        </DataGrid.Columns>
    </DataGrid>

SelectCommand is only a MessageBox.Show

(thank you and sorry for my english)




Get Some of Bean values inside attributs on html tag?

the listBean is already fill with data this is what i want to achieve :

<html:checkbox name="listBean" 
        property="checked" indexed="true" 
        disabled="listBean[i].disabled" />

this what i have tried :

    <bean:define id="disabledVal" name="listBean" property="disabled"/>
    <html:checkbox name="listBean" 
    property="checked" indexed="true" 
    disabled="<%=disabledVal%>" />

this code throws me a jsp error :

BWEB004062: Unable to compile class for JSP: JBWEB004060: An error occurred at line ### : 119 in the jsp file: .jsp The method setDisabled(boolean) in the type BaseHandlerTag is not applicable for the arguments (Object) 116: codeFonctionnalite="<%= NAME %>"> 117: 118: 119: 122: JBWEB004060: An error occurred at line: 136 in the jsp file: .jsp The method setDisabled(boolean) in the type BaseHandlerTag is not applicable for the arguments (Object) 133: 135: 136: 138: 139: JBWEB004211: Stacktrace:'




mardi 26 novembre 2019

How to update database base on laravel checkbox value

I load check boxes from database with they are checked or not,

  <div class="row">
                <div class="col-xs-12">
                    <div class="form-group">

                        @php
                            $json = $orders->data;
                            $json = json_decode($json, true);
                            $products = $json['order_info']['products'];

                            $data = '';

                                foreach ($products as $hitsIndex => $hitsValue) {
                                    $data .= $hitsValue['type']. ', ';
                                }
                            $data = rtrim($data, ', ');

                            $agosProducts = Utility::constant('agos_products1');
                        @endphp

                        
                        <label for="products" class="control-label"></label><br><br>

                        @foreach($agosProducts as $product)

                                    <label class="control-label "for="">
                                        <input id="" name="" type="checkbox" value=""
                                               @foreach ($products as $hitsIndex => $hitsValue)
                                                    @if(in_array($hitsValue['type'], $product)) checked=checked @endif
                                               @endforeach
                                        >
                                        
                                    </label>
                                <br>

                        @endforeach

                    </div>
                </div>
            </div

Now i want to update my database base on checkbox value.

For example if say i load checkbox 1 as checked from database and now it's unchecked i need to update it in database.

This code i can get all the current status of checkbox but i don't know previous values of this to update in database,

$chks = array('multicolor','resizable','showRuler','namesNumbersEnabled');
foreach ($chks as $chk) {
   $product->setAttribute($chk, (Input::has($chk)) ? true : false);
}

Can someone helps me?




React JS Prevent onClick from Firing when Checkbox is checked

I have a Card component with checkboxes. When a user clicks on a card, another Suggest component opens. However, when user clicks on checkbox, the onClick function runs also, still opening the Suggestions component. If there are no suggestions then it returns, and in that case the checkboxes work fine. I tried using preventDefault and stopPropagation, which I included stopPropagation the code below. Any help greatly appreciated.

import React, { useState } from "react";

const onUpdateCB = (e,ischecked, loginuser, userid, setisChecked,handleCheck) => {
 e.stopPropagation();
  console.log(ischecked, loginuser, userid);

  fetch('http://localhost:3000/cb', {
      method: 'post',
      headers: {'Content-Type':'application/json'},
      body:JSON.stringify({
      loginuser,
      userid,
      ischecked: ischecked
    })
  }).then(setisChecked(ischecked));
  return

};

const Card = props => {
  const [isChecked, setisChecked] = useState(props.ischecked);
  return (
    <div
      className="pointer bg-light-green dib br3 pa3 ma2 shadow-5"
      onClick={() => props.handleClick(props.id)}

    >
      <div>
        <h3>{props.name}</h3>
        <p>{props.company}</p>
        <p>{props.phone}</p>
        <p>{props.email}</p>
        <p>{props.city}</p>
      </div>
      <div>
        My Network
        <input
          className="largeCheckbox"
          type="checkbox"
          checked={isChecked}
          onChange={(e) =>
            onUpdateCB(e,!isChecked, props.loginuser.id, props.id, setisChecked)
          }
        />
      </div>
    </div>
  );
};

HandleClick function

handleClick(id) {
    const updatedSuggest = suggest.map(sugg => {
      if (sugg.id === id) {
        this.setState({
          suggest: suggest.filter(suggest => suggest.id === id),
          route: "suggestions"
        });
        this.setState({ routed: true });
        this.setState({
          networkfilter: this.state.network.filter(netw => netw.id === id),
          route: "suggestions"
        });
        this.setState({ routed: true });
      }
      return;
    });
  }



React form checkbox state not changing correctly

I have a form with four checkboxes that I'm tracking the value. Initially, the state of the checkboxes is set to false, but when I 'check' the box for the first time, the state remains false, and then when I 'uncheck' it, it turns to true. From that point the checkbox state holds the opposite value of what it's supposed to be.

Component code:


class GuestForm extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      yoga: false,
      detox: false,
      massage: false,
      breath: false
    };

    this.onCheckboxChange = this.onCheckboxChange.bind(this);
  }


  onCheckboxChange(event) {
    const target = event.target;
    const value = target.type === 'checkbox' ? target.checked : target.value;
    const name = target.name;

    this.setState({
      [name]: value
    });
  }

  render() {
    return (
      <form>
        <label>
          Activity Preferences:
          <label>
            <input 
              type='checkbox' 
              name='yoga'
              id='yoga'
              checked={this.state.yoga}
              onChange={this.onCheckboxChange} 
            />
            Yoga
          </label>
          <label>
            <input
              type='checkbox'
              name='detox'
              id='detox'
              checked={this.state.detox}
              onChange={this.onCheckboxChange}
            />
            Juice Detox
          </label>
          <label>
            <input
              type='checkbox'
              name='breath'
              id='breath'
              checked={this.state.breath}
              onChange={this.onCheckboxChange}
            />
            Breath-work
          </label>
          <label>
            <input
              type='checkbox'
              name='massage'
              id='massage'
              onChange={this.onCheckboxChange}
              value={this.state.massage}
            />
            Massage
          </label>
        </label>
        <input type='submit' value='Submit' />
      </form>
    );
  }
}

export default GuestForm;



Make the checkbox non editable by the user but editable programatically

and I want to restrict the user from changing it. I should be able to change it programatically but not by the user
I have tried, editable, clickable out did not work.

Can you please suggest on how it should be done please

Thanks R

 <LinearLayout
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:baselineAligned="false"
                android:paddingLeft="8dip"
                android:paddingRight="8dip">

                <androidx.appcompat.widget.AppCompatCheckBox
                    android:id="@+id/flight_origin_date"
                    style="@style/InputCheckBox"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:text="@string/new_order_flight_origin_date"
                    android:visibility="visible"
                    android:layout_weight="1"
                    android:layout_marginBottom="0dp"
                    app:buttonTint="@color/i6_teal" />

            </LinearLayout>



How do I create a tickbox that deletes all the cells in a row in google sheet?

I would like to create a tick bot here : enter image description here

So what it does is if I select the tick on for exemple the first row, it just deletes all the data on that row (and leaving the timestamp as it is, just deleting all the data for exemple the 5 / 454 / 54 / 54)

Because what I want to do is for exemple as you can see some cells are blank, and I don't want to count the entire row if one of the cells inside that row is blank.




CSS: Custom Toggle switch

I want to build a custom toggle switch, which has a Google maps like pin instead of a circle.

Therefore I did the following:

HTML

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">

</head>
<body>

<h2>Toggle Switch</h2>

<label class="switch">
  <input type="checkbox">
  <span class="slider"></span>
</label>

</body>
</html> 

CSS

.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 40px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  left: 4px;
  bottom: 10px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
  width: 20px;
  height: 20px;
  border-radius: 0 50% 50% 50%;
  border: 3px solid black;
  transform: rotate(225deg);
  margin-top: 20px;
}



input:checked + .slider {
  background-color: #2196F3;
}

input:focus + .slider {
  box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
  -webkit-transform: translateX(26px);
  -ms-transform: translateX(26px);
  transform: translateX(26px);
}

It is nearly what I was trying to do. But I need the pin to be rotated until the 'arrowhead' points to the bottom again. So a full rotation.

Is that somehow possible?

You can find my code here: https://codepen.io/lsgit/pen/GRRbrQq

Thanks in advance.




lundi 25 novembre 2019

Checkbox functionallity in treeview

https://codepen.io/chriscoyier/pen/JYyXjX I want to add this type of checkbox functionallity in my code. And It work from last child to it's grant parent. - When I check parent it's all child should be selected. - When I uncheck of it's one child then parent also unchecked. - When I check all child parent will auto selected. You can see all the functionallity in above codepen link.

$(document).ready(function(){

        var id = 0;
        var idnew = 0;
        var idSub = 0;
        var chkBoxId = 0; 
        
        var parentdiv = $("<ul class='parentdiv'></ul>");
        $(".main").append(parentdiv); 
        $(".icon .mAddClick").click(function(){

                idnew++;                
                var $maindiv = $("<li id='idnew"+idnew+"' class='flW100'><input id ='chkBoxId"+idnew+"' type='checkbox' class='chkBoxCls'><input type='text' class='inputCls'><a  class='rightBtn'><i class='fas fa-check'></i></a> <p class='lableTxt'></p>   <div class='edtDelBody'> <a class='deleteBtn'><i class='fas fa-times'></i></a>  <a class='editBtn'><i class='fas fa-pen'></i></a><a  class='addSubDivBtn'><i class='fas fa-plus'></i></a>  </div> </li>");
                $(parentdiv).append($maindiv);
                $('input[type=text]').focus();

                $("input[type=text]").keypress(function(event) { 
                        if (event.keyCode === 13) { 
                                $(".rightBtn").click(); 
                        } 
                });
        });

        $(".mdeleteClick").on("click",function(){      
                $("input:checked").parent().parent().remove();
                $(".icon1 .mdeleteClick").hide();
        });
        
        $("body").on("click",".rightBtn",function(){     
                var inputval = $(this).siblings('.inputCls').val();
                if (inputval == ''){
                        alert("please enter your task");
                        
                }else{
                        $(this).siblings('.lableTxt').show();
                        $(this).siblings('.lableTxt').text(inputval);
                        $(this).siblings('.inputCls').hide();           
                        $(this).hide();
                        $(this).siblings('.edtDelBody').show();                         
                }
        });  

        $("body").on("click",".deleteBtn",function(){
                $(this).parent().parent().parent().remove();
        });     

        $("body").on("click",".editBtn",function(){
                $(this).parent('.edtDelBody').hide();   
                $(this).parent().siblings('.lableTxt').hide();
                $(this).parent().siblings('.inputCls').show();  
                $(this).parent().siblings('.inputCls').focus();
                $(this).parent().siblings('.rightBtn').show();           
        });      

        $("body").on("click",".addSubDivBtn",function(){                  
                idSub++;
                var subdiv1 = $("<ul class='subsec'></ul>");
                $(this).parent('.edtDelBody').parent($(".flW100")).append(subdiv1);     
                var $subdiv = $("<li class='subdiv'><input id ='chkBoxId"+idnew+"' type='checkbox' class='chkBoxCls'><input type='text' class='subinputcls inputCls'> <a  class='rightBtn'><i class='fas fa-check'></i></a> <p class='lableTxt'></p>   <div class='edtDelBody'> <a class='deleteBtn'><i class='fas fa-times'></i></a>  <a class='editBtn'><i class='fas fa-pen'></i></a><a  class='addSubDivBtn'><i class='fas fa-plus'></i></a>  </div></li>");
                $(subdiv1).append($subdiv);
                $('.subinputcls').focus();

                $("input[type=text]").keypress(function(event) { 
                        if (event.keyCode === 13) { 
                                $(".rightBtn").click(); 
                        } 
                });
        }); 

//      $("body").on("change",".chkBoxCls",function(e) {
//              e.preventDefault();
//              e.stopPropagation();
//              $(this).each(function () {
//                      var a=$("input:checked").length;
//                      console.log(a);
//                      if(a>=2){$(".icon1 .mdeleteClick").show();}
//                      else if(a<=1){$(".icon1 .mdeleteClick").hide();}
//              });

//              console.log("Enter in loop");
//              var checked = $(this).prop("checked"),
//              container = $(this).parent(),
//              siblings = container.parent().siblings("ul");
//              console.log(checked);
//              console.log(container);
//              console.log(siblings);

//              container.find('input[type="checkbox"]').prop({
//                      checked: checked
//              });

//              function checkSiblings(el) {

//                      console.log("check for condition");
//                      var parent = el.parent().parent(),
//                      all = true;
//                      console.log(parent);
//                      console.log(el);

//                      el.parent().siblings("ul").each(function() {
//                              console.log("siblings");
//                              console.log(this);
//                              var returnValue = all = ($(this).find("li").children('input[type="checkbox"]').prop("checked") === checked);
//                              return returnValue;
//                      });

//                      console.log(all);

//                      if (all && checked) {
//                              console.log("all && checked");
//                              console.log(parent);
//                              parent.children('input[type="checkbox"]').prop({
//                                      checked: checked
//                              });

//                              // checkSiblings(parent);
//                              // return false;
//                              setTimeout(checkSiblings(parent), 30);

//                      } else if (all && !checked) {
//                              console.log("sdsadsadsa");
//                              parent.children('input[type="checkbox"]').prop("checked", checked);
//                              // checkSiblings(parent);
//                              // return false;
//                              setTimeout(checkSiblings(parent), 30);

//                      } else {
//                              console.log("else");
//                              console.log(el);
//                              el.parents("li").children('input[type="checkbox"]').prop({
//                                      checked: false
//                              });

//                      }
//              }
//              checkSiblings(container);
//      });     
});
* {
  box-sizing: border-box;
  user-select: none;
}

body{display: flex;
  background: #fff;
  justify-content: center;
  align-items: center;}
 ul,li{padding: 0px;margin: 0px;list-style:none;}
.content,.main,.header{width: 100%;float: left}
a:hover{text-decoration: none;}
.header{padding:10px;border-bottom:1px solid #a2a2a2;background-color:#fff;}
.main{width:50%;margin-left: 50%;transform: translateX(-50%);/*box-shadow: 0 4px 3px rgba(0,0,0,0.2);*/padding: 0 0 10px 0;}
.heading{width:auto;float: left}
.heading h4{margin:5px 0 0 0;}
.icon,.icon1{float:right;width:auto;}
.icon:hover{cursor: pointer;}
.subitem{width:100%;float:left;box-shadow: 0px 3px 4px -1px rgba(0, 0, 0, 0.15);}
.flW100{width:100%;float:left; padding:10px;background-color:#fff;margin:6px 0;border:1px solid #e0e0e0;}
.chkBoxCls{float:left;margin:14px 0 0 !important; }
.inputCls{float:left; width:50%;border-radius: 15px;border: 1px solid #b3b2b2;padding:2px 10px;margin:6px 0 0 10px;}
.inputCls:focus{outline: 0px;}
.rightBtn{float:right;padding:10px 0 0;}
.rightBtn i{font-size:18px;color: #4C6EF5;font-weight: bold;}
.rightBtn:hover{text-decoration: none;cursor: pointer;}
.edtDelBody{ display:none;}
.editBtn{float:right;margin:5px 10px; }
.deleteBtn{float:right;margin:7px 0 0 0;}
.deleteBtn:hover{cursor: pointer;}
.deleteBtn i{ color:#f15c5c;font-size:18px;font-weight:600;}
.addSubDivBtn{float:right;margin: 6px 0 0 0;}
.addSubDivBtn i{ color:#03C;font-size: 20px;font-weight: 600;}
.addSubDivBtn i:hover{cursor: pointer;}
.lableTxt{ display:none; float:left;margin:9px 0 0 10px;text-overflow: ellipsis;overflow: hidden;width:150px;white-space: nowrap;}
.editicon{width:16px;height:16px;}
.editicon:hover{cursor: pointer;}
.mdeleteClick{display: none;color: #ff0000;font-size:20px;}
.mdeleteClick:hover{cursor: pointer;}
.subdiv{float: left;width: 100%;}
.icon1{margin: 8px 8px 0 0;}
.mAddClick{font-size:20px;color:#1c23eb;font-weight:600;margin:8px 0 0 0;}
.parentdiv{float: left;width: 100%;}
.subsec{width: 100%;float: left;padding: 0 0 0 10px;}
.editBtn:hover,.deleteBtn:hover,.addSubDivBtn:hover{background-color:#f9f6f6;box-shadow: 0px 2px 2px 1px rgba(0,0,0,0.2);}
.editBtn, .deleteBtn, .addSubDivBtn {height: 30px;width: 30px;display: flex;border-radius: 50%;align-items: center;justify-content: center;}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="content">
                <div class="container">
                        <div class="main">
                                <div class="header">
                                        <span class="heading"><h4>Add New Task</h4></span><span class="icon"><i class="fas fa-plus mAddClick"></i></span><span class="icon1"><i class="far fa-trash-alt mdeleteClick"></i></span>
                                </div>
                        </div>
                </div>
        </div>
Thanks In advance to help me.


why checkbox, list of collection dosen't work in rails 5

I want to choose from a collection, i tried the code below, but it render only the values and the levels of AttributeType not the collection of check_boxes containing these values.

my form_file:

 <%= simple_form_for @rule do |f| %>


      <%= f.input :id  ,class:"form-control form-control-lg",placeholder: 'The id of your rule' %>

      <p class="control">
      <%= f.collection_check_boxes :at_suj, AttributeType.all, :value, :level do |m| %>
        <%= m.label class: 'checkbox' do %>
          <%= m.check_box class: 'checkbox' %>
          <%= m.text %>

          <% end %>
          <% end %>
        </p>
      </div>
  <div class="actions"> 
    <%= f.button :submit, class:"btn btn-success btn-rounded ",title:"cliquer pour créer cette règle" %>
    <% end %>

where is the problem!




C# CheckBox List Sending only checked boxes to Word Document

I'm writing an application where the user can log what items are checked out to students, and print that information to a Word document for the student to sign. The WinForm has 6 CheckBoxes that can be chosen. I have some code that almost works, but still isn't quite giving me the formatted bulleted list of only checked items that I want. Here's the code I have so far:

// Add list of checked-out items to Document
Microsoft.Office.Interop.Word.Paragraph ul = doc.Content.Paragraphs.Add(ref missing);
ul.Range.ListFormat.ApplyBulletDefault();

if (listItem1CheckBx.Checked)
{
    ul.Range.ListFormat.ApplyBulletDefault();
    ul.Range.InsertBefore(listItem1CheckBx.Text + "\n");
}
if (listItem2CheckBx.Checked)
{
    ul.Range.ListFormat.ApplyBulletDefault();
    ul.Range.InsertBefore(listItem2CheckBx.Text + "\n");
}
if (listItem3CheckBx.Checked)
{
    ul.Range.ListFormat.ApplyBulletDefault();
    ul.Range.InsertBefore(listItem3CheckBx.Text + "\n");
}
if (listItem4CheckBx.Checked)
{
    ul.Range.ListFormat.ApplyBulletDefault();
    ul.Range.InsertBefore(listItem4CheckBx.Text + "\n");
}
if (listItem5CheckBx.Checked)
{
    ul.Range.ListFormat.ApplyBulletDefault();
    ul.Range.InsertBefore(listItem5CheckBx.Text + "\n");
}
if (otherChckBx.Checked)
{
    ul.Range.ListFormat.ApplyBulletDefault();
    ul.Range.InsertAfter(otherListItemTxtBx.Text);
}

How can I make this work better and possibly clean up the code at the same time?




JavaFX: display stored CheckBoxTreeItem selection in TreeView

I use a treeView to select sections which later shall be displayed on a report. To improve the user-friendliness I decided to save the selection, so the user doesn't have to select the same sections the next time again. I have saved the selections, but when the view is initialized, the treeView doesn't display the selection properly (img 1). I'm looking for a way that displays the treeView as it is shown in img 2.

public class Main extends Application {
    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        CheckBoxTreeItem<String> rootItem = new CheckBoxTreeItem<>("Root");

        CheckBoxTreeItem<String> aItem = new CheckBoxTreeItem<>("A");

        CheckBoxTreeItem<String> a1Item = new CheckBoxTreeItem<>("A_1");
        CheckBoxTreeItem<String> a2Item = new CheckBoxTreeItem<>("A_2");

        CheckBoxTreeItem<String> bItem = new CheckBoxTreeItem<>("B");
        CheckBoxTreeItem<String> cItem = new CheckBoxTreeItem<>("C");

        a1Item.setSelected(true);
        aItem.setExpanded(true);

        aItem.getChildren().addAll(a1Item, a2Item);

        rootItem.getChildren().addAll(aItem, bItem, cItem);
        rootItem.setExpanded(true);

        TreeView treeView = new TreeView(rootItem);
        treeView.setCellFactory(CheckBoxTreeCell.<String>forTreeView());

        Scene scene = new Scene(treeView, 400, 400);
        scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}

how it looks at the start how it should look at the start




update columns and multiple updates by checkBox the columes

This feels like it shouldn't be an easy one. How do I update my sql server table by checkBox with the columns name ;

DROP TABLE #indebtedness
CREATE TABLE [dbo].[indebtedness](
[Subscriber_No] [bigint] NULL,
[Subscriber_Name] [nvarchar](max) NULL,
[Last_Deact_Date] [date] NULL,
[allocated] [decimal](18, 3) NULL,
[collected] [numeric](18, 3) NOT NULL,
[ID_No] [bigint] NULL,

I'm using desktop application with c# code I look for have to checkBox to update the column from dataGridView

i use something like this code to update my database

 int countSuccess = 0;
            for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
            {
                // INSERT command:
                using (SqlCommand com = new SqlCommand("UPDATE indebtedness SET autodialtype=@autodialtype,autodial=@autodial,autodate=@autodate,lastdate=@lastdate,lastcall_case=@lastcall_case WHERE  Subscriber_No=@Subscriber_No and company_name=@company_name and indebtedness_name=@indebtedness_name", con))
                {

                    com.Parameters.AddWithValue("@company_name", company_name.Text);
                    com.Parameters.AddWithValue("@indebtedness_name", indebtedness_name.Text);
                    com.Parameters.AddWithValue("@Subscriber_No", dataGridView1.Rows[i].Cells[0].Value);
                    com.Parameters.AddWithValue("@autodialtype", dataGridView1.Rows[i].Cells[1].Value);
                    com.Parameters.AddWithValue("@autodial", "Called");
                    com.Parameters.AddWithValue("@autodate", DateTime.Today.ToShortDateString());
                    com.Parameters.AddWithValue("@lastcall_case", "AutoDial");
                    com.Parameters.AddWithValue("@lastdate", DateTime.Today.ToShortDateString());


                    int numUpd = com.ExecuteNonQuery();

                    countSuccess += numUpd;


                    //com.ExecuteNonQuery();
                }

            }

            MessageBox.Show($"Successfully UPDATED {countSuccess} of {dataGridView1.Rows.Count} rows");

from loke like

I just want to update the column that I check for update only




check if a checkbox is checked in angular

I have a list of checkboxes, and there is a certain input text that I want to show only near a checkbox that is checked. In AngularJs it is very very simple. In angular it seems impossible. I saw this question with many answers, none of them worked! Can anyone give me a simple working solution?

Thanks, Osnat.

Here is my code:

<tr *ngFor="let eachService of services; let i = index">
     <td class="service-td" *ngIf="services[i]"><input type="checkbox">
          <span></span>
     </td>
     <input [hidden]="???" type="text" value="wl">
</tr>




how to write validation code for checkbox

i'm newbie please help me, and i have datatable

    unitid   date(textbox)       checkbox
    id2323  01/01/2019(input)     check
    id2323  01/01/2019(input)     check
    id2323  01/02/2019(input)
    id2324  01/01/2019(input)

when saved, show the message
lblMessage.Text = "date cannot be the same";

        unitid   date(textbox)       checkbox
        id2323  01/01/2019(input)     check
        id2323  01/01/2019(input)     
        id2323  01/02/2019(input)     check
        id2324  01/01/2019(input)

when saved, show the message   
lblMessage.Text = "save succesfull"; 

thanks




Select All list in Listview With Custom Adapter

I have a listview that I want to implement checkbox with option "SelectAll"

this is the fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">

                <androidx.appcompat.widget.SearchView
                    android:id="@+id/Searchrecord"
                    android:layout_width="230dp"
                    android:layout_height="wrap_content" />

                <CheckBox
                    android:id="@+id/checkBox"
                    android:layout_width="119dp"
                    android:layout_height="match_parent"
                    android:text="Select All" />
            </LinearLayout>

            <ListView
                android:id="@+id/to_print"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:choiceMode="multipleChoice"
                />

</LinearLayout>

Here is the Code inside the fragment

public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        toolsViewModel = ViewModelProviders.of(this).get(ToolsViewModel.class);
        final View root = inflater.inflate(R.layout.fragment_tools, container, false);

        selectall = root.findViewById(R.id.checkBox);
        selectall.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                int itemCount = toprintlist.getCount();
                for(int i=0 ; i < itemCount ; i++)
                    toprintlist.setItemChecked(i, selectall.isChecked());
            }
        });

        toprintlist = root.findViewById(R.id.to_print);
        toprintlist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                int checkedItemCount = getCheckedItemCount();

                if(toprintlist.getCount()==checkedItemCount)
                    selectall.setChecked(true);
                else
                    selectall.setChecked(false);
            }
        });
    }

this is my adapter class

public class toprintAdapter extends BaseAdapter
{
        Context context;
        ArrayList<String> account;
        ArrayList<String> name;
        ArrayList<String> address;
        ArrayList<String> meter_number;
        ArrayList<String> multiplier;
        ArrayList<String> type;
        ArrayList<String> billing_period_year;
        ArrayList<String> billing_period_month;
        ArrayList<String> last_reading;
        ArrayList<String> last_date_record;
        ArrayList<String> gen_system_charge;
        ArrayList<String> trans_system_chg;
        ArrayList<String> system_loss_chg;
        ArrayList<String> distr_system_chg;
        ArrayList<String> supply_system_chg;
        ArrayList<String> supply_retail_chg;
        ArrayList<String> meter_system_chg;
        ArrayList<String> meter_retail_chg;
        ArrayList<String> rsfc;
        ArrayList<String> life_line_subsidy;
        ArrayList<String> ppa_refund;
        ArrayList<String> iccs_adjustment;
        ArrayList<String> generation_vat;
        ArrayList<String> transmission_vat;
        ArrayList<String> system_loss_vat;
        ArrayList<String> distribution_vat;
        ArrayList<String> others_vat;
        ArrayList<String> senior_citizen_subsidy;
        ArrayList<String> fit_all;
        ArrayList<String> missionary_elec_spug;
        ArrayList<String> envir_charge;
        ArrayList<String> stranded_contract_cost;
        ArrayList<String> npc_scc_debt;
        ArrayList<String> current_reading;
        ArrayList<String> current_reading_date;
        ArrayList<String> kwh_used;
        ArrayList<String> total_gen_system_charge;
        ArrayList<String> toal_trans_system_chg;
        ArrayList<String> total_system_loss_chg;
        ArrayList<String> total_distr_system_chg;
        ArrayList<String> total_supply_system_chg;
        ArrayList<String> total_supply_retail_chg;
        ArrayList<String> total_meter_system_chg;
        ArrayList<String> total_meter_retail_chg;
        ArrayList<String> total_rsfc;
        ArrayList<String> total_life_line_subsidy;
        ArrayList<String> total_ppa_refund;
        ArrayList<String> total_iccs_adjustment;
        ArrayList<String> total_generation_vat;
        ArrayList<String> total_transmission_vat;
        ArrayList<String> total_system_loss_vat;
        ArrayList<String> total_distribution_vat;
        ArrayList<String> total_others_vat;

        public toprintAdapter(Context context2, ArrayList<String> account, ArrayList<String> name, ArrayList<String> address, ArrayList<String> meter_number, ArrayList<String> multiplier, ArrayList<String> type, ArrayList<String> billing_period_year, ArrayList<String> billing_period_month, ArrayList<String> last_reading, ArrayList<String> last_date_record, ArrayList<String> gen_system_charge, ArrayList<String> trans_system_chg, ArrayList<String> system_loss_chg, ArrayList<String> distr_system_chg, ArrayList<String> supply_system_chg, ArrayList<String> supply_retail_chg, ArrayList<String> meter_system_chg, ArrayList<String> meter_retail_chg, ArrayList<String> rsfc, ArrayList<String> life_line_subsidy, ArrayList<String> ppa_refund, ArrayList<String> iccs_adjustment, ArrayList<String> generation_vat, ArrayList<String> transmission_vat, ArrayList<String> system_loss_vat, ArrayList<String> distribution_vat, ArrayList<String> others_vat, ArrayList<String> senior_citizen_subsidy, ArrayList<String> fit_all, ArrayList<String> missionary_elec_spug, ArrayList<String> envir_charge, ArrayList<String> stranded_contract_cost, ArrayList<String> npc_scc_debt, ArrayList<String> current_reading, ArrayList<String> current_reading_date, ArrayList<String> kwh_used, ArrayList<String> total_gen_system_charge, ArrayList<String> toal_trans_system_chg, ArrayList<String> total_system_loss_chg, ArrayList<String> total_distr_system_chg, ArrayList<String> total_supply_system_chg, ArrayList<String> total_supply_retail_chg, ArrayList<String> total_meter_system_chg, ArrayList<String> total_meter_retail_chg, ArrayList<String> total_rsfc, ArrayList<String> total_life_line_subsidy, ArrayList<String> total_ppa_refund, ArrayList<String> total_iccs_adjustment, ArrayList<String> total_generation_vat, ArrayList<String> total_transmission_vat, ArrayList<String> total_system_loss_vat, ArrayList<String> total_distribution_vat, ArrayList<String> total_others_vat, ArrayList<String> ) {
                this.context = context2;
                this.account = account;
                this.name = name;
                this.address = address;
                this.meter_number = meter_number;
                this.multiplier = multiplier;
                this.type = type;
                this.billing_period_year = billing_period_year;
                this.billing_period_month = billing_period_month;
                this.last_reading = last_reading;
                this.last_date_record = last_date_record;
                this.gen_system_charge = gen_system_charge;
                this.trans_system_chg = trans_system_chg;
                this.system_loss_chg = system_loss_chg;
                this.distr_system_chg = distr_system_chg;
                this.supply_system_chg = supply_system_chg;
                this.supply_retail_chg = supply_retail_chg;
                this.meter_system_chg = meter_system_chg;
                this.meter_retail_chg = meter_retail_chg;
                this.rsfc = rsfc;
                this.life_line_subsidy = life_line_subsidy;
                this.ppa_refund = ppa_refund;
                this.iccs_adjustment = iccs_adjustment;
                this.generation_vat = generation_vat;
                this.transmission_vat = transmission_vat;
                this.system_loss_vat = system_loss_vat;
                this.distribution_vat = distribution_vat;
                this.others_vat = others_vat;
                this.senior_citizen_subsidy = senior_citizen_subsidy;
                this.fit_all = fit_all;
                this.missionary_elec_spug = missionary_elec_spug;
                this.envir_charge = envir_charge;
                this.stranded_contract_cost = stranded_contract_cost;
                this.npc_scc_debt = npc_scc_debt;
                this.current_reading = current_reading;
                this.current_reading_date = current_reading_date;
                this.kwh_used = kwh_used;
                this.total_gen_system_charge = total_gen_system_charge;
                this.toal_trans_system_chg = toal_trans_system_chg;
                this.total_system_loss_chg = total_system_loss_chg;
                this.total_distr_system_chg = total_distr_system_chg;
                this.total_supply_system_chg = total_supply_system_chg;
                this.total_supply_retail_chg = total_supply_retail_chg;
                this.total_meter_system_chg = total_meter_system_chg;
                this.total_meter_retail_chg = total_meter_retail_chg;
                this.total_rsfc = total_rsfc;
                this.total_life_line_subsidy = total_life_line_subsidy;
                this.total_ppa_refund = total_ppa_refund;
                this.total_iccs_adjustment = total_iccs_adjustment;
                this.total_generation_vat = total_generation_vat;
                this.total_transmission_vat = total_transmission_vat;
                this.total_system_loss_vat = total_system_loss_vat;
                this.total_distribution_vat = total_distribution_vat;
                this.total_others_vat = total_others_vat;   
        }


        public int getCount() {
                return account.size();
        }

        public Object getItem(int position) {
                return null;
        }

        public long getItemId(int position) {
                return 0L;
        }

        @Override
        public View getView(int position, View child, ViewGroup parent) {

                toprintAdapter.Holder holder;
                if (child == null) {
                        @SuppressLint("WrongConstant") LayoutInflater layoutInflater = (LayoutInflater) this.context.getSystemService("layout_inflater");
                        child = layoutInflater.inflate(R.layout.meter_reading_to_print, null);
                        holder = new toprintAdapter.Holder();
                        holder.textprintdefaultaccount = child.findViewById(R.id.p_account_no);
                        holder.textprintdefaultname = child.findViewById(R.id.p_name);
                        holder.textprintdefaultaddress = child.findViewById(R.id.p_address);
                        holder.textprintdefaultmeter_number = child.findViewById(R.id.p_meter_number);
                        holder.textprintdefaultmultiplier = child.findViewById(R.id.p_multiplier);
                        holder.textprintdefaulttype = child.findViewById(R.id.p_type);
                        holder.textprintdefaultbilling_period_year = child.findViewById(R.id.p_billing_period_year);
                        holder.textprintdefaultbilling_period_month = child.findViewById(R.id.p_billing_period_month);
                        holder.textprintdefaultlast_reading = child.findViewById(R.id.p_last_reading);
                        holder.textprintdefaultlast_date_record = child.findViewById(R.id.p_last_record_date_reading);
                        holder.textprintdefaultgen_system_charge = child.findViewById(R.id.p_rate_gen_system_charge);
                        holder.textprintdefaulttrans_system_chg = child.findViewById(R.id.p_rate_trans_system_chg);
                        holder.textprintdefaultsystem_loss_chg = child.findViewById(R.id.p_rate_system_loss_chg);
                        holder.textprintdefaultdistr_system_chg = child.findViewById(R.id.p_rate_distr_system_chg);
                        holder.textprintdefaultsupply_system_chg = child.findViewById(R.id.p_rate_supply_system_chg);
                        holder.textprintdefaultsupply_retail_chg = child.findViewById(R.id.p_rate_supply_retail_chg);
                        holder.textprintdefaultmeter_system_chg = child.findViewById(R.id.p_rate_meter_system_chg);
                        holder.textprintdefaultmeter_retail_chg = child.findViewById(R.id.p_rate_meter_retail_chg);
                        holder.textprintdefaultrsfc = child.findViewById(R.id.p_rate_rsfc);
                        holder.textprintdefaultlife_line_subsidy = child.findViewById(R.id.p_rate_life_line_subsidy);
                        holder.textprintdefaultppa_refund = child.findViewById(R.id.p_rate_ppa_refund);
                        holder.textprintdefaulticcs_adjustment = child.findViewById(R.id.p_rate_iccs_adjsutment);
                        holder.textprintdefaultgeneration_vat = child.findViewById(R.id.p_rate_generation_vat);
                        holder.textprintdefaulttransmission_vat = child.findViewById(R.id.p_rate_transmission_vat);
                        holder.textprintdefaultsystem_loss_vat = child.findViewById(R.id.p_rate_system_loss_vat);
                        holder.textprintdefaultdistribution_vat = child.findViewById(R.id.p_rate_distribution_vat);
                        holder.textprintdefaultothers_vat = child.findViewById(R.id.p_rate_others_vat);
                        holder.textprintdefaultsenior_citizen_subsidy = child.findViewById(R.id.p_rate_senior_ctzn_subsidy);
                        holder.textprintdefaultfit_all = child.findViewById(R.id.p_rate_fit_all);
                        holder.textprintdefaultmissionary_elec_spug = child.findViewById(R.id.p_rate_missnry_elec_spug);
                        holder.textprintdefaultenvir_charge = child.findViewById(R.id.p_rate_envir_charge);
                        holder.textprintdefaultstranded_contract_cost = child.findViewById(R.id.p_rate_strndd_cntrct_cst);
                        holder.textprintdefaultnpc_scc_debt = child.findViewById(R.id.p_rate_npc_scc_debt);
                        holder.textloadcurrent_reading = child.findViewById(R.id.p_current_reading);
                        holder.textloadcurrent_reading_date = child.findViewById(R.id.p_current_date_reading);
                        holder.texttotalkwh_used = child.findViewById(R.id.p_kwh_used);
                        holder.texttotal_gen_system_charge = child.findViewById(R.id.p_total_gen_system_charge);
                        holder.texttotal_trans_system_chg = child.findViewById(R.id.p_total_trans_system_chg);
                        holder.texttotal_system_loss_chg = child.findViewById(R.id.p_total_system_loss_chg);
                        holder.texttotal_distr_system_chg = child.findViewById(R.id.p_total_distr_system_chg);
                        holder.texttotal_supply_system_chg = child.findViewById(R.id.p_total_supply_system_chg);
                        holder.texttotal_supply_retail_chg = child.findViewById(R.id.p_total_supply_retail_chg);
                        holder.texttotal_meter_system_chg = child.findViewById(R.id.p_total_meter_system_chg);
                        holder.texttotal_meter_retail_chg = child.findViewById(R.id.p_total_meter_retail_chg);
                        holder.texttotal_rsfc = child.findViewById(R.id.p_total_rsfc);
                        holder.texttotal_life_line_subsidy = child.findViewById(R.id.p_total_life_line_subsidy);
                        holder.texttotal_ppa_refund = child.findViewById(R.id.p_total_ppa_refund);
                        holder.texttotal_iccs_adjustment = child.findViewById(R.id.p_total_iccs_adjsutment);
                        holder.texttotal_generation_vat = child.findViewById(R.id.p_total_generation_vat);
                        holder.texttotal_transmission_vat = child.findViewById(R.id.p_total_transmission_vat);
                        holder.texttotal_system_loss_vat = child.findViewById(R.id.p_total_system_loss_vat);
                        holder.texttotal_distribution_vat = child.findViewById(R.id.p_total_distribution_vat);
                        holder.texttotal_others_vat = child.findViewById(R.id.p_total_others_vat);

                        child.setTag(holder);
                }
                else
                {
                        holder = (toprintAdapter.Holder)child.getTag();
                }
                holder.textprintdefaultaccount.setText(this.account.get(position));
                holder.textprintdefaultname.setText(this.name.get(position));
                holder.textprintdefaultaddress.setText(this.address.get(position));
                holder.textprintdefaultmeter_number.setText(this.meter_number.get(position));
                holder.textprintdefaultmultiplier.setText(this.multiplier.get(position));
                holder.textprintdefaulttype.setText(this.type.get(position));
                holder.textprintdefaultbilling_period_year.setText(this.billing_period_year.get(position));
                holder.textprintdefaultbilling_period_month.setText(this.billing_period_month.get(position));
                holder.textprintdefaultlast_reading.setText(this.last_reading.get(position));
                holder.textprintdefaultlast_date_record.setText(this.last_date_record.get(position));
                holder.textprintdefaultgen_system_charge.setText(this.gen_system_charge.get(position));
                holder.textprintdefaulttrans_system_chg.setText(this.trans_system_chg.get(position));
                holder.textprintdefaultsystem_loss_chg.setText(this.system_loss_chg.get(position));
                holder.textprintdefaultdistr_system_chg.setText(this.distr_system_chg.get(position));
                holder.textprintdefaultsupply_system_chg.setText(this.supply_system_chg.get(position));
                holder.textprintdefaultsupply_retail_chg.setText(this.supply_retail_chg.get(position));
                holder.textprintdefaultmeter_system_chg.setText(this.meter_system_chg.get(position));
                holder.textprintdefaultmeter_retail_chg.setText(this.meter_retail_chg.get(position));
                holder.textprintdefaultrsfc.setText(this.rsfc.get(position));
                holder.textprintdefaultlife_line_subsidy.setText(this.life_line_subsidy.get(position));
                holder.textprintdefaultppa_refund.setText(this.ppa_refund.get(position));
                holder.textprintdefaulticcs_adjustment.setText(this.iccs_adjustment.get(position));
                holder.textprintdefaultgeneration_vat.setText(this.generation_vat.get(position));
                holder.textprintdefaulttransmission_vat.setText(this.transmission_vat.get(position));
                holder.textprintdefaultsystem_loss_vat.setText(this.system_loss_vat.get(position));
                holder.textprintdefaultdistribution_vat.setText(this.distribution_vat.get(position));
                holder.textprintdefaultothers_vat.setText(this.others_vat.get(position));
                holder.textprintdefaultsenior_citizen_subsidy.setText(this.senior_citizen_subsidy.get(position));
                holder.textprintdefaultfit_all.setText(this.fit_all.get(position));
                holder.textprintdefaultmissionary_elec_spug.setText(this.missionary_elec_spug.get(position));
                holder.textprintdefaultenvir_charge.setText(this.envir_charge.get(position));
                holder.textprintdefaultstranded_contract_cost.setText(this.stranded_contract_cost.get(position));
                holder.textprintdefaultnpc_scc_debt.setText(this.npc_scc_debt.get(position));
                holder.textloadcurrent_reading.setText(this.current_reading.get(position));
                holder.textloadcurrent_reading_date.setText(this.current_reading_date.get(position));
                holder.texttotalkwh_used.setText(this.kwh_used.get(position));
                holder.texttotal_gen_system_charge.setText(this.total_gen_system_charge.get(position));
                holder.texttotal_trans_system_chg.setText(this.toal_trans_system_chg.get(position));
                holder.texttotal_system_loss_chg.setText(this.total_system_loss_chg.get(position));
                holder.texttotal_distr_system_chg.setText(this.total_distr_system_chg.get(position));
                holder.texttotal_supply_system_chg.setText(this.total_supply_system_chg.get(position));
                holder.texttotal_supply_retail_chg.setText(this.total_supply_retail_chg.get(position));
                holder.texttotal_meter_system_chg.setText(this.total_meter_system_chg.get(position));
                holder.texttotal_meter_retail_chg.setText(this.total_meter_retail_chg.get(position));
                holder.texttotal_rsfc.setText(this.total_rsfc.get(position));
                holder.texttotal_life_line_subsidy.setText(this.total_life_line_subsidy.get(position));
                holder.texttotal_ppa_refund.setText(this.total_ppa_refund.get(position));
                holder.texttotal_iccs_adjustment.setText(this.total_iccs_adjustment.get(position));
                holder.texttotal_generation_vat.setText(this.total_generation_vat.get(position));
                holder.texttotal_transmission_vat.setText(this.total_transmission_vat.get(position));
                holder.texttotal_system_loss_vat.setText(this.total_system_loss_vat.get(position));
                holder.texttotal_distribution_vat.setText(this.total_distribution_vat.get(position));
                holder.texttotal_others_vat.setText(this.total_others_vat.get(position));               
                return child;
        }

        public class Holder
        {
                TextView textprintdefaultaccount;
                TextView textprintdefaultname;
                TextView textprintdefaultaddress;
                TextView textprintdefaultmeter_number;
                TextView textprintdefaultmultiplier;
                TextView textprintdefaulttype;
                TextView textprintdefaultbilling_period_year;
                TextView textprintdefaultbilling_period_month;
                TextView textprintdefaultlast_reading;
                TextView textprintdefaultlast_date_record;
                TextView textprintdefaultgen_system_charge;
                TextView textprintdefaulttrans_system_chg;
                TextView textprintdefaultsystem_loss_chg;
                TextView textprintdefaultdistr_system_chg;
                TextView textprintdefaultsupply_system_chg;
                TextView textprintdefaultsupply_retail_chg;
                TextView textprintdefaultmeter_system_chg;
                TextView textprintdefaultmeter_retail_chg;
                TextView textprintdefaultrsfc;
                TextView textprintdefaultlife_line_subsidy;
                TextView textprintdefaultppa_refund;
                TextView textprintdefaulticcs_adjustment;
                TextView textprintdefaultgeneration_vat;
                TextView textprintdefaulttransmission_vat;
                TextView textprintdefaultsystem_loss_vat;
                TextView textprintdefaultdistribution_vat;
                TextView textprintdefaultothers_vat;
                TextView textprintdefaultsenior_citizen_subsidy;
                TextView textprintdefaultfit_all;
                TextView textprintdefaultmissionary_elec_spug;
                TextView textprintdefaultenvir_charge;
                TextView textprintdefaultstranded_contract_cost;
                TextView textprintdefaultnpc_scc_debt;
                TextView textloadcurrent_reading;
                TextView textloadcurrent_reading_date;
                TextView texttotalkwh_used;
                TextView texttotal_gen_system_charge;
                TextView texttotal_trans_system_chg;
                TextView texttotal_system_loss_chg;
                TextView texttotal_distr_system_chg;
                TextView texttotal_supply_system_chg;
                TextView texttotal_supply_retail_chg;
                TextView texttotal_meter_system_chg;
                TextView texttotal_meter_retail_chg;
                TextView texttotal_rsfc;
                TextView texttotal_life_line_subsidy;
                TextView texttotal_ppa_refund;
                TextView texttotal_iccs_adjustment;
                TextView texttotal_generation_vat;
                TextView texttotal_transmission_vat;
                TextView texttotal_system_loss_vat;
                TextView texttotal_distribution_vat;
                TextView texttotal_others_vat;            
                public Holder()
                {

                }
        }
}

I want to get this function I saw in [http://wptrafficanalyzer.in/blog/implementing-checkall-and-uncheckall-for-a-listview-in-android/#comment-1163160]

enter image description here

But I can't since I'm using Custom Layout, can someone help me? It's not giving an error but there's also no check function on the listview item