Wednesday, 2 October 2019

How do I save ionic 4 question data inside of sqlite db using ionic storage?

What I do is pull the the basic question data from sqlite using this code.

ts

openKeyValueTEST(value: string) {
  this.storage.get(value).then((val) => {
    this.auditTwoResults = JSON.parse(val);
    this.auditTwo = this.auditTwoResults.compliantTest;
    this.formNameTwo = value;
  });
}

The

this.formNameTwo = value

is this,

  "compliantTest": [
    { 
      questionnum: '1', 
      question: 'Some question', 
      text_name: 'text1', 
      radio_name: 'rad1', 
      select_name: 'sel1',  
      id: 'id1' 
    },
    { 
      questionnum: '2', 
      question: 'question again?', 
      text_name: 'text2', 
      radio_name: 'rad2', 
      select_name: 'sel2', 
      id: 'id2' }
  ],

What I am trying to accomplish is making my form persistent. The user may be out of cell coverage or take a day or two to fill out the form. If possible i would like to to overwrite the

this.formNameTwo

to include the filled out form data.

My form data will consist of text, radio buttons, and select. Below is an example of my form. When I can I will be placing a bounty on this question.

      <ion-card-content>
        <div class="question">
            
        </div>

        <ion-radio-group  name="">         
          <ion-row class="radio-tags">
            <ion-item class="radio-tag" lines="none">
              <ion-label class="tag-label">compliant</ion-label>
              <ion-radio value="compliant" (click)="closeSelect(i)"></ion-radio>
            </ion-item>
            <ion-item class="radio-tagtwo" lines="none">
              <ion-label class="tag-label">non-compliant</ion-label>
              <ion-radio value="non-compliant" (click)="openSelect(i)"></ion-radio>
            </ion-item>
          </ion-row>
        </ion-radio-group>

        <div *ngIf="show[i]">
          <div>
            <ion-item >
              <ion-label position="floating">Findings Title</ion-label>
              <ion-textarea name=""></ion-textarea>
            </ion-item>

            <ion-item>
              <ion-label class="ion-text-wrap">Company or Contractor</ion-label>
              <ion-select placeholder="Select" name="">
                <ion-select-option value="1">1</ion-select-option>
                <ion-select-option value="2">2</ion-select-option>
              </ion-select>
            </ion-item>
          </div>
        </div>
      </ion-card-content>


from How do I save ionic 4 question data inside of sqlite db using ionic storage?

No comments:

Post a Comment