Author Topic: i need a hint  (Read 1410 times)

arbyter

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 35
    • View Profile
i need a hint
« on: July 05, 2019, 10:54:44 pm »
hi
i want to have a picklist that contains all different entrys in current column. I manged it by this snippet.
autocomplete ... source: function (grid,ui){               
                    var ret = []
                    var data=grid.getData({dataIndx:[ui.dataIndx]})
                    $(data).each(function(i,v){if(v[ui.dataIndx])ret.push(v[ui.dataIndx])})
                    return (ret)}
So far, so good.
Now i am stuck with this:
when i leave the field, i should complete with the first matching value found in the list, without the need to choose by key or mousclick.
Example; i enter  a , the list contains Armada, Bravo, Mountain then it should autocomplete with Armada on leaving the field.
Maybe you can provide me a hint.

arbyter

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: i need a hint
« Reply #1 on: July 09, 2019, 01:43:23 pm »
i change slightly the goal to achieve.
When the user leaves a empty field with Enter Key, then it should fill in the value from the direct neighbour (down) record.

this snippet performs well, but then it clears the injected value on blur
 editorEnd:function(e,ui){if(ui.\$cell.val()==''){
                                                    var id=ui.\$td[0].id.split('-');
                                                    id[4]=parseInt(id[4])+1;
                                                    ui.$cell.text($('#'+id.join('-')).text());
                                                    this.saveEditCell()}                               
                                                                                    },

how can i save the injected value?

arbyter

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: i need a hint
« Reply #2 on: July 10, 2019, 10:22:47 pm »
after experimenting several hours this snippet does the trick:
    editorKeyDown:function(e,ui){if(e.currentTarget.value=='' && e.keyCode==13){
                                                    var id=ui.$td[0].id.split('-');
                                                    id[4]=parseInt(id[4])+1;
                                                    $('.pq-editor-focus').val($('#'+id.join('-')).text())}                               
                                                                                    }
tried it with events editorEnd and cellBevoreSave, value got allways cleared.