Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Show/Hide only selected records in isc.ListGrid by checkbox

    Dear all,
    I try to make an special filter on my ListGrid, where faced the problem, and spend much time without any result:
    Description:
    I have a simple form with one checkbox and one ListGrid where get records from DataSource, where get data via dataURL (ofcourse Json format)
    The ListGrid have selectionAppearance:"checkbox"
    we need: when I check the checkbox from DynamicForm, must filter list grid and show only selected field (where is ckecked)
    but i dunno how to do it.
    One of my vision is to add one more hidden field with type boolean and when record is selecte place in that field the true value, and when i click to DynamicForm checkbox i set the criteria by that hidden field. This solution work only if I use testData with an arrayObjects of countries in DataSource, if i use dataURL then that example not work.

    Problem:
    1. How to set default value of my hidden field (when i debug i see all value is undefined)
    2. how can I set the filter to default generated checkbox, means ( selectionAppearance:"checkbox") without any supplementary hidden fields

    isc_version=v11.0p_2016-05-14 and v9.1 also problem

    Code:
    isc.DataSource.create({
            ID: "countryDS",
            clientOnly:true,
            dataURL: "/data/xmlrpc/.....",
            fields:[
                {name:"countryCode", title:"Code", primaryKey:true},
                {name:"countryName", title:"Country"},
                {name:"filterFlag", title:"hide", type:"boolean"}
            ],
            //testData: countryData
        });
    
    isc.ListGrid.create({
        ID: "countryList",
        width:500, height:224, alternateRecordStyles:true,showRowNumbers:true,
        autoFetchData:true,
        selectionAppearance:"checkbox",
        dataSource: countryDS,
        selectionChanged: function(item, isChecked) {
            item.filterFlag = isChecked;
        },
        fields:[
            {name:"countryCode", title:"Code"},
            {name:"countryName", title:"Country"},
            {name:"filterFlag", title:"Filter", type:"boolean", canEdit: true, /*visibility:false, hidden: true, defaultValue:true*/ }
        ]
    });
    
    isc.DynamicForm.create({
        ID: "form_normal_supplier_test3",
        left:360, top:220,
        fields: [
            {name:"showSelected", title:"Show selected", showTitle: true,  type:"checkbox", width: "*", align:"left",  titleAlign :"right",
                changed: function (form, item, value) {
                    if (value == true){
                        countryList.setCriteria({"filterFlag": true});
                    } else {
                        countryList.clearCriteria();
                    }
            }},
        ]
    });
    PS. Please help me ;(
    Last edited by icevic1; 3 Jun 2016, 05:17.

    #2
    You mention your dataURL approach isn't working, but you didn't show an example of what data is being returned. Whatever is being returned, it's not becoming valid boolean data (you mentioned seeing it as undefined). Fix your returned data so it becomes booleans (either by correcting what your server returns, or patching over the problem using dataSource.transformResponse) and then filtering will work the same way it does with a clientOnly DataSource.

    Comment


      #3
      but before any fixes how to do by that approach:
      2. how can I set the filter to default generated checkbox, means ( selectionAppearance:"checkbox") without any supplementary hidden fields
      PS. I can't believe what i want isn't possible, or some developers not implement this. Isomortphic is big/usual/ util and very nice framework but i unknown how to solve this problem.
      Last edited by icevic1; 19 May 2016, 00:10.

      Comment


        #4
        The problem at the moment is not a framework limitation, but simply that we can't actually figure out what your question means...

        If you want to filter by a field that renders as a checkbox, create a boolean field (which will render as a checkbox by default), and leave that field visible.

        Then just turn off selectionAppearance:"checkbox". The selection feature is for temporary tracking of selection within a given end user's browser, considering only the currently loaded data. If you are trying to filter by some permanent boolean attribute of stored records, this is totally unrelated to selection, and trying to combine the two is just leading to confusion.

        Comment


          #5
          Sorry for my insistence
          Maybe problem is other?

          My filter working only if run in debug console console (Firefox) the:
          Code:
          gridSuppliersList.data.getAllRows().map(function (item) { return item.filterFlag; });
          after that the filter working perfectly, if not run this code in console the filter not work

          how can i understand why?, and how keep it permanently work without run any supplementary code manually in debug console.

          Comment


            #6
            Yes, manually filtering the data array after making selections would be expected to work for the reasons we explained above. Re-read what we said before, and also take a look at the ResultSet class overview.

            Comment


              #7
              oh sorry, i'm newly to using SmartClint framework, and also my english is bad, and not understand all your mentioned
              could you provide please some example with code (based on above example) how to fix?

              Comment


                #8
                Dear Admin,
                I fixed the returned data from the server, now i have boolean field, taked visble, and filter by it working, thanks!

                but an other issue was come:
                - when I check the checkbox on that listgrid (name:"filterFlag") i need set the record as selected, how to mark the current rector as selected?

                I understated for that must use method changed
                Code:
                changed: function (form, item, value) {
                     /* how to set current record as selected ????????*/
                }

                Comment


                  #9
                  this seems to work:

                  Code:
                  isc.ListGrid.create({
                      ID: "countryList",
                      width: 550, height: 224, alternateRecordStyles: true,
                      // use server-side dataSource so edits are retained across page transitions
                      dataSource: countryDS,
                      selectionType: "simple",
                      fields: [
                          {name: "countryCode", title: "Flag", width: 40, type: "image", imageURLPrefix: "flags/16/", imageURLSuffix: ".png", canEdit: false},
                          {name: "countryName"},
                          {name: "continent"},
                          {
                              name: "member_g8",
                              recordClick: function (viewer, record, recordNum, field, fieldNum, value, rawValue) {
                                  if (record.member_g8) {
                                      viewer.deselectRecord(record);
                                  } else {
                                      viewer.selectRecord(record)
                                  }
                              }
                          },
                          {name: "population"},
                          {name: "independence"}
                      ],
                      autoFetchData: true,
                      canEdit: true
                  })
                  note: it doesn't work if you don't use selectionType: "simple", which to me seems a bug...

                  Comment

                  Working...
                  X