/*  Mouse down the cell value and put it in the mouse-up cell */
/*
그리드에서 마우스다운한 셀 값 가져다(드레그 해서) 마우스업한 셀에 넣기 */



<html>
<head>
</head>
<link rel="stylesheet" type="text/css" charset="UTF-8" href="./theme-gray-all.css" />


<style type="text/css">
</style>


<script type="text/javascript" charset="UTF-8" src="./ext-all.js"></script>


<body>


<script language='javascript' >


var val_click;


Ext.onReady(function(){


  Ext.define('User', {
      extend: 'Ext.data.Model',
      fields: [ 'name', 'email', 'phone' ]
  });


  var userStore = Ext.create('Ext.data.Store', {
      model: 'User',
      data: [
         { name: 'Lisa', email: 'lisa@simpsons.com', phone: '555-111-1221' },
         { name: 'Bart', email: 'bart@simpsons.com', phone: '555-222-1232' },
         { name: 'Homer', email: 'homer@simpsons.com', phone: '555-222-1243' },
         { name: 'Marge', email: 'marge@simpsons.com', phone: '555-222-1254' }
      ]
  });


  Ext.create('Ext.grid.Panel', {
      renderTo: document.body,
      store: userStore,
      width: 400,
      height: 200,
      title: 'Application Users',
      editable : true, 
      columns: [
          {
              text: 'Name',
              width: 100,
              sortable: false,
              hideable: false,
              dataIndex: 'name'
          },
          {
              text: 'Email Address',
              width: 150,
              dataIndex: 'email',
              hidden: true
          },
          {
              text: 'Phone Number',
              flex: 1,
              dataIndex: 'phone' ,          
              editable: true
          }
      ] ,
      listeners: {
   'cellmousedown': function(iView, iCellEl, iColIdx, iStore, 
                                         iRowEl, iRowIdx, iEvent) {
           var rec = this.getStore().getAt(iRowIdx);
           var val2 = this.columns[iColIdx].dataIndex;
           val_click =  rec.get(  val2  );
           console.log(' value :: ' + val_click );
   },
   'cellmouseup': function(iView, iCellEl, iColIdx, iStore, 
                                      iRowEl, iRowIdx, iEvent) {
           var rec = this.getStore().getAt(iRowIdx);
           var val2 = this.columns[iColIdx].dataIndex;        
            rec.set(  val2  , val_click   );
   }
      }      
  }); 
});




</script>
<title>Simple Grid Sample for ExtJs</title>
</body>
</html>




 

 

Posted by 혜화초보
,



 


<html>

<head>

</head>


<script  language="javascript"  >


function init(){


  var hoy1  = document.getElementById('hoy');


  //인풋박스안에 클릭을 했다가 다른곳 클릭을 해야

  //실행되는 이벤트 리스너.

  // An event listener that is executed after 

  // clicking in the input box and clicking elsewhere.  

  hoy1.addEventListener("blur", func1 , false);

  

  

  //포커스만 되도 실행되는 리스너

  //A listener that will be executed even if the focus is reached

  hoy1.addEventListener("focus", func2 , false);


}



function func1(){  

  console.log( ' hoy 1');

}


function func2(){  

  console.log( ' hoy 2');

}


</script>

    <body  onload="init();" >

        <input type='text'  size='20'    id='hoy'   >

    </body>

</html>








'[.js] 이벤트' 카테고리의 다른 글

붙여넣기 이벤트 처리 ctrl+v  (0) 2017.09.06
div 에다가 클릭 이벤트 걸기  (0) 2017.09.06
Posted by 혜화초보
,

 

 




<html>
<head>
</head>


<script  language="javascript"  >


 /*Click and drag to follow the div */


 var div_a1;


 function init(){
   div_a1 = document.getElementById('a1');
   var groundDiv = document.getElementById('groundDiv');
   groundDiv.addEventListener('mousedown', mouseDown);
   groundDiv.addEventListener('mousemove', mouseMove);
   groundDiv.addEventListener('mouseup', mouseUp);
 }


 var isClick = false; 
 function mouseDown(e){
   isClick = true;
 }
 
 function mouseMove(e){
   if( isClick == true ){
     div_a1.style.left = e.offsetX - 20 + 'px';
     div_a1.style.top = e.offsetY - 20 + 'px';     
   }
 }
 
 function mouseUp(e){
   isClick = false;
 }


</script>
    <body  onload="init();" >
        <div id="groundDiv"  style="position:relative; width:99%; height:99%; border:0x solid black;"></div>
        <div id='a1'  style="position:absolute; width:3px; height:3px; border:2px solid black;top:2px;left:3px  " ></div>
    </body>
</html>




 

 

Posted by 혜화초보
,

 

/*

텍스트 필드에 값을 붙여 넣은 경우 그 값에서 공백을

콤마로 치환하는 예제.

 

If you paste a value into a text field,

Example of replacing with a comma.

*/

 

 

<html>

<head>

</head>

<link rel="stylesheet" type="text/css" charset="UTF-8" href="./theme-gray-all.css" />

 

<style type="text/css">

</style>

 

<script type="text/javascript" charset="UTF-8" src="./ext-all.js"></script>

 

<body>

 

<script language='javascript' >

 

Ext.onReady(function(){

 

  Ext.create('Ext.form.Panel', {

      title: 'Contact Info',

      width: 300,

      bodyPadding: 10,

      renderTo: Ext.getBody(),

      items: [{

          xtype: 'textfield',

          name: 'name',

          fieldLabel: 'Name',

          allowBlank: false  // requires a non-empty value

          ,

          listeners: {

            paste: {

              element: 'inputEl',

              fn: function(event, inputEl) {

               setTimeout(function(){

                 var temp1 = ( inputEl.value  ).replace(/ /g,",");

                 inputEl.value = temp1;

               },0);

              }

            }

          }

      }, {

          xtype: 'textfield',

          name: 'email',

          fieldLabel: 'Email Address',

          vtype: 'email'  // requires value to be a valid email address format

      }]

  });

    

    

});

Posted by 혜화초보
,