'Programming/JQuery'에 해당하는 글 5건

설명 : 양식 요소 집합을 제출 문자열로 인코딩합니다. .serialize() 메서드는 표준 URL 인코딩 표기법으로 텍스트 문자열을 만듭니다.

          <input> , <textarea> , <select> 와 같은 개별 폼 컨트롤을 선택한 jQuery 객체에서 작동 할 수 있습니다.

 

 

 

<form id="frm"> <select name = "single" id="single"> <option selected = "selected"> Single </ option> <option > Single2 </ option> </select> <select name = "multiple" multiple = "multiple" id="multiple> <option selected = "selected" > Multiple </ option> <option > Multiple2 </option> <option selected = "selected" > Multiple3 </ option> </select> <input type = "checkbox" name = "check" value = "check1" id = "ch1" > <label for = "ch1" > check1 </label> <input type = "checkbox" name = "check" value = "check2" checked = "checked" id = "ch2" > <label for = "ch2" > check2 </label> <input type = "radio" name = "radio" value = "radio1" checked = "checked" id = "r1" > <label for = "r1" > radio1 </label> <input type = "radio" name = "radio" value = "radio2" id = "r2"> <label for = "r2" > radio2 </label> </form>

 

위의 form 태그안에 <input>, <textarea>, <select> 와 같은 개별 요소들을 직렬화 합니다. 물론 개별요소들도 각각 직렬화가 가능합니다.

 

 

function TEST(){
		alert($('#frm').serialize());
		$.ajax({
			url : '${pageContext.request.contextPath}/test/test.do',
			type : 'POST',
			dataType : 'HTML',
			data : $('#frm').serialize(),
			success : function(result) {
 
				/* TODO : */
			}
		})
	}

 

 

위의 TEST 함수처럼 ajax호출시 전송하는 data 부분에 .serialize를 사용하면 id가 frm인 form의 요소들을 직렬화 하여 전송합니다.

 

"single=Single&multiple=Multiple&check=ch2&radio=r1" 와 같이 스트링 형식으로 만들어 냅니다.

 

 

참고 : "성공적인 컨트롤" 만 문자열로 직렬화됩니다. 단추를 사용하여 양식을 제출하지 않았으므로 제출 단추 값이 직렬화되지 않습니다. 양식 요소의 값을 직렬화 된 문자열에 포함하려면 요소에 name 특성이 있어야합니다. 체크 박스와 라디오 버튼 ( "라디오"또는 "체크 박스"유형의 input 의 값은 체크 된 경우에만 포함됩니다. 파일 선택 요소의 데이터는 직렬화되지 않습니다.

 

 

'Programming > JQuery' 카테고리의 다른 글

jQuery에서의 Deferred와 Promise  (0) 2016.12.20
jqGgrid Rowspan  (0) 2016.12.19
JqGrid Row Colspan 하는법  (0) 2016.11.16
JqGrid Header Colspan 하는법  (0) 2016.11.07

WRITTEN BY
사자봉구

,
http://djawl_2.blog.me/50184671092

 

'Programming > JQuery' 카테고리의 다른 글

JQuery .serialize()의 사용  (0) 2017.01.12
jqGgrid Rowspan  (0) 2016.12.19
JqGrid Row Colspan 하는법  (0) 2016.11.16
JqGrid Header Colspan 하는법  (0) 2016.11.07

WRITTEN BY
사자봉구

,

jqGgrid Rowspan

Programming/JQuery 2016. 12. 19. 12:28
http://stackoverflow.com/questions/12200621/jqgrid-grouping-row-level-data

 

'Programming > JQuery' 카테고리의 다른 글

JQuery .serialize()의 사용  (0) 2017.01.12
jQuery에서의 Deferred와 Promise  (0) 2016.12.20
JqGrid Row Colspan 하는법  (0) 2016.11.16
JqGrid Header Colspan 하는법  (0) 2016.11.07

WRITTEN BY
사자봉구

,

JqGrid를 사용할 때 Row를 Colspan 하는방법.

 

colModel의 cellAttr을 이용하여 처리한다. 기준이 되는 칼럼에 'colspan=2' 옵션, colspan할 칼럼에 style="display:none" 옵션을 적용한다. (25 ~ 28Line)

 

같은 방식으로 style속성을 바꿀 수 있다. ex) style="text-align:center" 등등..

 

$(document).ready(function () {
            var mydata = [
                    {id:"1", invdate:"2007-10-01",name:"test_test_test_test_test",  note:"note",  amount:"200.00",tax:"10.00",closed:true, ship_via:"TN",total:"210.00"},
                    {id:"2", invdate:"2007-10-02",name:"test2222222222222222", note:"note2", amount:"300.00",tax:"20.00",closed:false,ship_via:"FE",total:"320.00"},
                    {id:"3", invdate:"2007-09-01",name:"test3", note:"note3", amount:"400.00",tax:"30.00",closed:false,ship_via:"FE",total:"430.00"},
                    {id:"4", invdate:"2007-10-04",name:"test4444444444444444", note:"note4", amount:"200.00",tax:"10.00",closed:true ,ship_via:"TN",total:"210.00"},
                    {id:"5", invdate:"2007-10-31",name:"test5", note:"note5", amount:"300.00",tax:"20.00",closed:false,ship_via:"FE",total:"320.00"},
                    {id:"6", invdate:"2007-09-06",name:"test6", note:"note6", amount:"400.00",tax:"30.00",closed:false,ship_via:"FE",total:"430.00"},
                    {id:"7", invdate:"2007-10-04",name:"test7", note:"note7", amount:"200.00",tax:"10.00",closed:true ,ship_via:"TN",total:"210.00"},
                    {id:"8", invdate:"2007-10-03",name:"test8", note:"note8", amount:"300.00",tax:"20.00",closed:false,ship_via:"FE",total:"320.00"},
                    {id:"9", invdate:"2007-09-01",name:"test9", note:"note9", amount:"400.00",tax:"30.00",closed:false,ship_via:"TN",total:"430.00"},
                    {id:"10",invdate:"2007-09-08",name:"test10",note:"note10",amount:"500.00",tax:"30.00",closed:true ,ship_via:"TN",total:"530.00"},
                    {id:"11",invdate:"2007-09-08",name:"test11",note:"note11",amount:"500.00",tax:"30.00",closed:false,ship_via:"FE",total:"530.00"},
                    {id:"12",invdate:"2007-09-10",name:"test12",note:"note12",amount:"500.00",tax:"30.00",closed:false,ship_via:"FE",total:"530.00"}
                ],
                grid = $("#list");

            grid.jqGrid({
                datatype:'local',
                data: mydata,
                colNames:['Inv No','Date','Client A','Client B','Amount','Tax','Total','Closed','Shipped via','Notes'],
                colModel:[
                    {name:'id',index:'id',width:70,align:'center',sorttype: 'int'},
                    {name:'invdate',index:'invdate',width:80, align:'center', sorttype:'date', formatter:'date', formatoptions: {newformat:'d-M-Y'}, datefmt: 'd-M-Y'},
                    {name:'name',index:'name', width:70, 
                      cellattr: function(rowId, tv, rawObject, cm, rdata) {  if (Number(rowId) < 5) { return ' colspan=2' }} },
                    {name:'nameB',index:'nameB', width:70, 
                      cellattr: function(rowId, tv, rawObject, cm, rdata) {  if (Number(rowId) < 5) { return ' style="display:none;"' }}},
                    {name:'amount',index:'amount',width:100, formatter:'number', align:'right'},
                    {name:'tax',index:'tax',width:70, formatter:'number', align:'right'},
                    {name:'total',index:'total',width:120, formatter:'number', align:'right'},
                    {name:'closed',index:'closed',width:110,align:'center', formatter: 'checkbox', edittype:'checkbox',editoptions:{value:'Yes:No',defaultValue:'Yes'}},
                    {name:'ship_via',index:'ship_via',width:120,align:'center',formatter:'select',  edittype:'select',editoptions:{value:'FE:FedEx;TN:TNT;IN:Intim',defaultValue:'Intime'}},
                    {name:'note',index:'note',width:100,sortable:false}
                ],
                rowNum:10,
                rowList:[5,10,20],
                pager: '#pager',
                gridview:true,
                rownumbers:true,
                sortname: 'invdate',
                viewrecords: true,
                sortorder: 'desc',
                caption:'Just simple local grid',
                height: '100%'
            });
        });

 

 

 

출처 : http://www.ok-soft-gmbh.com/jqGrid/SimpleLocalGridCellMerge.htm

'Programming > JQuery' 카테고리의 다른 글

JQuery .serialize()의 사용  (0) 2017.01.12
jQuery에서의 Deferred와 Promise  (0) 2016.12.20
jqGgrid Rowspan  (0) 2016.12.19
JqGrid Header Colspan 하는법  (0) 2016.11.07

WRITTEN BY
사자봉구

,

JqGrid를 사용할 때 Header를 Colspan 하는방법.

 

위에 그리드 헤더 중 수량단위를 Colspan 하려고 한다.

 

 

 

우선 그리드를 하나 생성한 뒤 newWidth변수에 cnt와 stand칼럼의 width를 합하고 cnt칼럼에 setLabel 옵션을 주어 두 칼럼을 합한 width를 줍니다. 그리고 칼럼명 옆에 표시될 텍스틀 적어주면 된다. (21~26라인)

 

var colNameGrid = ['품명','한글','영문', '수량', '단위', '기타'];
var colModelGrid = [ 
	             {name:'pro', index:'pro', width:200, align:'center',  frozen : true},
	             {name:'kr', index:'kr', width:260, align:'center',  frozen : true},
	             {name:'en', index:'en', width:200, align:'center',  frozen : true},
	             {name:'cnt', index:'cnt', width:200, align:'center',  frozen : true},
	             {name:'stand', index:'stand', width:260, align:'center',  frozen : true},
	             {name:'etc', index:'etc', width:360, align:'center',  frozen : true}
	            ];
    
jQuery("#sub_grid").jqGrid({
    datatype: 'local',
    colNames : colNameGrid,
    colModel : colModelGrid,
    rowNum:10,
    rowList:[10,30,50],
    height:'220',
    width:'810',
});

var newWidth = $("#sub_grid_cnt").width() + $("#sub_grid_stand").outerWidth(true);
jQuery("#sub_grid").jqGrid("setLabel", "cnt", "수량 / 단위", "", {
		style: "width: " + newWidth + "px;",
		colspan: "2"
	});
jQuery("#sub_grid").jqGrid("setLabel", "stand", "", "", {style: "display: none"}); 

 

 

수량, 단위 칼럼이 "수량 / 단위" 로 Colspan되었다.

 

 

'Programming > JQuery' 카테고리의 다른 글

JQuery .serialize()의 사용  (0) 2017.01.12
jQuery에서의 Deferred와 Promise  (0) 2016.12.20
jqGgrid Rowspan  (0) 2016.12.19
JqGrid Row Colspan 하는법  (0) 2016.11.16

WRITTEN BY
사자봉구

,