Author Topic: How I can use pqselect as custom editor?  (Read 2793 times)

alandman

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 6
    • View Profile
How I can use pqselect as custom editor?
« on: October 18, 2016, 12:47:06 am »
Hi Paramvir,
I am using jquery 2.2.0 for one of my projects.

Right now I am using multiselect but there are some problems with it.
My Custom editor has some logic and depends on the row number is different.
For row #4 it should be multiselect. What is the easier way to implement it?
So far I have:
var abnrmCondEditor = function (ui) {
    var $cell = ui.$cell,
    rowData = ui.rowData,
    dataIndx = ui.dataIndx,
    cls = ui.cls,
    dc = $.trim(rowData[dataIndx]),
    wdth = ui.column.width-4;
       
    $.ajax({
        url: 'getAbnormalCodes.do',
        type: 'GET',
        dataType: "json",
        async: false,
        success:  function(json_arr) {
           if (json_arr) {
                  var options="", code, desc;
                  //alert(dc);
                  $.each(json_arr, function(i,val) {
                    code = val.valueIndx,
                    desc = val.labelIndx.toUpperCase();
                    
                    //alert("DC:"+dc);
                       if (dc && dc.toUpperCase() == desc) {
                          options = options + "<option selected='selected' value="+code+">"+desc+"</option>";
                       } else {
                          options = options + "<option value="+code+">"+desc+"</option>";
                       }
                   });
                  
                    var $dropdownField = $("<select name='" + dataIndx + "' class='"+cls+" grp-cmb-abnrml-cond pq-ac-editor' multiple='multiple'>"+options+"</select>")
                                        .appendTo($cell).val(dc.split(','));
      
                    $dropdownField.multiselect({
                      selectedList: 2,
                      minWidth: wdth,
                      noneSelectedText: "",
                      click: function() {
                         var selections = $.map($(this).multiselect("getChecked"),function( input ){
                            return input.value;
                         });

                         alert("Selections:" + selections);
                         $dropdownField.appendTo($cell).val(JSON.stringify(selections));

//                         //$("#grid_group_lc_hdr_2").pqGrid( "quitEditMode" );
                      },
                      close: function() {
                         $("#grid_group_lc_hdr_2").pqGrid("quitEditMode");
                      }
                    });
           } else {
              alert('Failed to upload Abnormal Conditions');
           }
        },
        error: function (xhr, ajaxOptions, thrownError) {
         alert('Failed to upload Abnormal Conditions');
        }
   });

}
« Last Edit: October 18, 2016, 01:50:40 am by alandman »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: How I can use pqselect as custom editor?
« Reply #1 on: October 18, 2016, 12:55:31 pm »
Row number ( rowIndx ) can be accessed from ui.rowIndx.

Hope it helps to write your custom logic based upon row number.

alandman

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: How I can use pqselect as custom editor?
« Reply #2 on: October 19, 2016, 01:24:26 am »
Sorry but the question was and still remains about using PQSelect in custom editor.
If you can give me example would be great.
So far all samples for pqselect related to fitering.

Dont worry about ui.rowIndx I am using it already.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: How I can use pqselect as custom editor?
« Reply #3 on: October 19, 2016, 10:42:04 am »
pqSelect is used as an inline editor in this example: http://paramquery.com/pro/demos/editing_custom in "Shipping Via" column.
« Last Edit: October 19, 2016, 07:24:59 pm by paramquery »