/* 기본 그리드 형태 */

/*  base grid style */


<html>
<head>
</head>
<link rel="stylesheet" type="text/css" media="screen" href="./jqueryUi/jquery-ui.css" />
<link rel="stylesheet" type="text/css" media="screen" href="./jqGrid/css/ui.jqgrid.css" />  
<style type="text/css">
</style>
<script src="./jqGrid/js/jquery-3.2.1.min.js"></script><script src="./jqueryUi/jquery-ui.js"></script>
<script src="./jqGrid/js/jquery.jqGrid.min.js"></script>
<script language='javascript' >




 $(function(){
     var gridData = [
        {seq:"1",date1:"2017/09/01",name1:"Homer",name2:"note",hitnum:"100"},
        {seq:"2",date1:"2017/10/02",name1:"Marge",name2:"note2",hitnum:"350"}  ];


     $("#list").jqGrid({
        datatype: "local",
        height: 300,
        colNames:['seq','name1', 'name2', 'date','hit'],
        colModel:[
                {name:'seq'},
                {name:'name1'},
                {name:'name2'},
                {name:'date1'},
                {name:'hitnum'}    
        ],
        caption: " title aa "
     });
         
     for(var i=0;i<=gridData.length;i++){
        $("#list").jqGrid('addRowData',i+1,gridData[i]);
     }
})






</script>
<body>


<table id="list"></table>


</body>
</html>


 

 

Posted by 혜화초보
,

 

 

 



/*  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 혜화초보
,