Author Topic: colModel editor custom button  (Read 6367 times)

omerix

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 148
    • View Profile
colModel editor custom button
« on: May 23, 2018, 12:54:45 pm »
Hello,

I am using the following code for the custom field.
Code: [Select]
         var HucreS = function (ui) {
             var $cell = ui.$cell,
                 rowData = ui.rowData,
                 dataIndx = ui.dataIndx,
                 width = parseInt(ui.column.width) - 40,
                 cls = ui.cls;
             var dc = $.trim(rowData[dataIndx]);
             $cell.append("<input type='text'  name='" + dataIndx + "' id='" + dataIndx + "' value='" + dc + "' class='" + cls + " fl ls'  style='z-index: 40000;width:" + width + "px;'/>"
                 +"<span class='ui-widget-header fl ek' onclick=\"window.parent.Popui('../ModGenel/Liste.asp?js=6&l=s&e=FrameOrder',782,483,'');\"><i class='ui-icon ui-icon-search ck'></i></span>"
                 +"<span class='ui-widget-header fl ek' onclick=\"window.parent.Popui('../ModStok/Kart.asp?menu=h&KOD="+dc+"',1044,521,'Stok Kart');\"><i class='ui-icon ui-icon-plus ck'></i></span>"
             );
//$cell.find("input").focus()
         };

Code: [Select]
",{title: 'Mal.Kodu',dataIndx:'MKOD',width:75,dataType:'string',editable:true,hidden:false,editor:{type:HucreS}}"&VbNewLine&_


In version 5.1. I can not use the special buttons next to the input. When I click the buttons, it leaves the field.
Video: https://youtu.be/ji5cAZ8Ww7k?t=13s


Version 2.2.0. There is no problem.
Video: https://youtu.be/ji5cAZ8Ww7k?t=38s


omerix

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 148
    • View Profile
Re: colModel editor custom button
« Reply #1 on: May 26, 2018, 12:17:35 pm »
Hello there,

"editModel: {onBlur: null}," when I clicked on the <span>.

But I could not write the values in the field on the line popup window.

How do I assign values to the columns in the row I click?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: colModel editor custom button
« Reply #2 on: May 28, 2018, 05:24:43 pm »
Could you please share a jsfiddle.

omerix

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 148
    • View Profile
Re: colModel editor custom button
« Reply #3 on: May 29, 2018, 05:09:06 pm »
Hello,

https://jsfiddle.net/omerx/2mm5y2fw/2/

Click on the "search" button in column A to open popup. I want to write a value to that cell.

Popup Command Button:
Code: [Select]
window.parent.frames[0].$('.pq-editor-focus').val('Test');

Can I set value the value by clicking on it in this way?;
Code: [Select]
<a href='#' Onclick="$grid('A','5').val('Test');">Set To Value A5 or 1/5</a>




Could you please share a jsfiddle.
« Last Edit: May 29, 2018, 05:13:18 pm by omerix »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: colModel editor custom button
« Reply #4 on: May 29, 2018, 11:27:24 pm »
Value can be written to editor by simply:

Code: [Select]
$('.pq-editor-focus').val('test')

https://jsfiddle.net/2mm5y2fw/3/

omerix

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 148
    • View Profile
Re: colModel editor custom button
« Reply #5 on: May 30, 2018, 11:16:42 am »
Hello Param,

Thanks for the answer

What can I do to write "Test2" to column "B" at the same time?


Also, the buttons move out of the column. I'm doing width-40, but is not that enough?
Is the "Custom Input Create" incorrect?
Code: [Select]
  var HucreS = function(ui) {
    var $cell = ui.$cell,
      rowData = ui.rowData,
      dataIndx = ui.dataIndx,
      width = parseInt(ui.column.width) - 40,
      cls = ui.cls;
    var dc = $.trim(rowData[dataIndx]);
    $cell.append("<input type='text'  name='" + dataIndx + "' id='" + dataIndx + "' value='" + dc + "' class='" + cls + " fl ls'  style='z-index: 40000;width:" + width + "px;'/>" +
      "<span class='ui-widget-header fl ek' onclick=\"$('.pq-editor-focus').val('test')\"><i class='ui-icon ui-icon-search ck'></i></span>" +
      "<span class='ui-widget-header fl ek' onclick=\"window.parent.Popui('../ModStok/Kart.asp?menu=h&KOD=" + dc + "',1044,521,'Stok Kart');\"><i class='ui-icon ui-icon-plus ck'></i></span>"
    );
    //$cell.find("input").focus()
  };

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: colModel editor custom button
« Reply #6 on: May 30, 2018, 11:03:26 pm »
Quote
What can I do to write "Test2" to column "B" at the same time?

Row information i.e. rowIndx can be obtained by getEditCell() and getCellIndices() methods.

https://paramquery.com/pro/api#method-getEditCell

https://paramquery.com/pro/api#method-getCellIndices

Test2 to column B can be written by

rowData[ dataIndx of column B ] = "Test2"

or by updateRow() API

https://paramquery.com/pro/api#method-updateRow

omerix

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 148
    • View Profile
Re: colModel editor custom button
« Reply #7 on: May 31, 2018, 11:42:18 pm »
Hello param,
Could you give me a simple sample code?


Quote
What can I do to write "Test2" to column "B" at the same time?

Row information i.e. rowIndx can be obtained by getEditCell() and getCellIndices() methods.

https://paramquery.com/pro/api#method-getEditCell

https://paramquery.com/pro/api#method-getCellIndices

Test2 to column B can be written by

rowData[ dataIndx of column B ] = "Test2"

or by updateRow() API

https://paramquery.com/pro/api#method-updateRow

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: colModel editor custom button
« Reply #8 on: June 01, 2018, 03:22:06 pm »
Please check this.

https://jsfiddle.net/2mm5y2fw/4/

Code: [Select]
$(document).on('click', ".ui-icon-search", function(){
  debugger;
  var obj = grid.getEditCell(),
    $editor = obj.$editor;
      $editor.val('test');
     var obj2 = grid.getCellIndices(obj);
     obj2.rowData[1] = "test2";
     
     grid.refreshCell({rowIndx: obj2.rowIndx, dataIndx: 1})
  })

omerix

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 148
    • View Profile
Re: colModel editor custom button
« Reply #9 on: June 02, 2018, 01:39:42 pm »
Thank you.

Nice code. I also review the "updateRow api" you recommend.