Easy UI DataGrid 실전



$(function(){
			var lastIndex;
			var $dg = $("#tt");
			$dg.datagrid({
				title : ' ',
				idField : 'field_result',
				loadMsg : ' , ......',
				fitColumns : true,
				//singleSelect : true,
				columns : [ [
				{
					checkbox : true,
                    width : $(this).width()*0.2,
				},
				{
	                field : 'fieldname',
	                title : ' ',
	                width : $(this).width()*0.4,
	                editor : {type:'validatebox',
                               options:{required:true}
                        }
	            }, {
	                field : 'isrequired',
	                title : ' ',
	                width : $(this).width()*0.4,
	                editor : {type:'combobox',
                                  options{required:true,
                                         panelHeight:'auto',
                                         valueField:'isqid',
                                          textField:'isqname',
                                               data: [{isqid:'0',isqname:' '},
                                                      {isqid:'1',isqname:' '}
                                               ]
                                  }
                         }
	            }] ],
				toolbar:[{
					text:' ',
					iconCls:'icon-add',
					handler:function(){
						$dg.datagrid('endEdit', lastIndex);
						$dg.datagrid('appendRow',{
							fieldname:'',
							isrequired:''
						});
						lastIndex = $dg.datagrid('getRows').length-1;
						$dg.datagrid('selectRow', lastIndex);
						$dg.datagrid('beginEdit', lastIndex);
                        // "uncheckRow" ,datagrid checkbox                         
                        $dg.datagrid('uncheckRow',lastIndex);
					}
				},'-',{
					text:' ',
					iconCls:'icon-remove',
					handler:function(){
                        //  checkbox 
						var rows = $dg.datagrid('getChecked');
						for(var i=0; i<rows.length; i++){
							var row = rows[i];
                            var index = $dg.datagrid('getRowIndex', row);
							$dg.datagrid('deleteRow', index);
                        }
					}
				},'-',{
					text:' ',
					iconCls:'icon-save',
					handler:function(){
						$dg.datagrid('acceptChanges');
						var inserted = $dg.datagrid('getRows');
                        //  
						var valid = $('#form').form('validate');  
	                    if(valid==true){
                            //  json 
	                    	$("#txtJsonField").val(JSON.stringify(inserted));
	                    }else{
	                    	$("#txtJsonField").val("");
	                    }
					}
				}],
				onBeforeLoad:function(){
					$dg.datagrid('rejectChanges');
				},
				onClickRow:function(rowIndex){
					if (lastIndex != rowIndex){
						$dg.datagrid('endEdit', lastIndex);
						$dg.datagrid('beginEdit', rowIndex);
					}
					lastIndex = rowIndex;
				}
			});
		});


좋은 웹페이지 즐겨찾기