// jqGird는 jqGrid를 가져올때 사용되는 table ID 값
//체크한 row의 id값 가져오기 배열형태
var rowid2 = $("#jqGrid").getGridParam("selarrrow");
// 반복문을 이용해서 Id에 해당하는 Row data값을 가져온다.
// 배열선언 (하나씩 불러와서 배열에 저장시키기 위해)
var array = new Array();
for(var i=0; i <= rowid2.length-1; i++){
//console.log(rowid2[0]);
//console.log(i);
// Id에 해당하는 rowData를 가져온다.
var selRowData = $("#jqGrid").getRowData(rowid2[i]);
//console.log(selRowData);
// 가져온 데이터를 배열에 저장
array.push(selRowData)
}
// 확인
console.log(array);
// json형태로 변환하여 확인
console.log(JSON.stringify(array));
// 원하는 JqGrid 컬럼에 fomatter 속성을 부여하고 함수를 설정해준다.
{ width:200, name:'REAL_ATTACH_FILE', index:'REAL_ATTACH_FILE', align:"center", sortable:true, editable:false, formatter:cutom_link},
// 선언한 함수 정의
function cutom_link(cellvalue, options, rowdata, action){
var id = cellvalue;
var name = rowdata.PO_LINE_ID;
var rowdata = rowdata.FILE_ID;
if(rowdata == null){
console.log("aaddd");
var html = '<SPAN class="btn_pack btn_white_01_small small" style="vertical-align:bottom"><A href="javascript:popupOpen(' + $.trim($(this).parent().attr('id')) + ');">첨부</A> </SPAN>';
} else {
console.log("rowdata: " + rowdata);
console.log("aaddd55555");
var html = '<a href="aaaa';
html += '?id=' + id;
html += '&line_id=' + name;
html += '&file_id=' + rowdata;
html += '">' + id + '</a>';
}
return html;
코드를 설명하면 해당 컬럼에 파일 id가 존재하면 파일명을 컬럼에 뿌려주고 없을 경우 버튼을 생성하여 업로드할 수 있는 기능을 만들었다.
// datepicker 호출하는 부분에 beforeShow 속성부분을 추가
$('.date_field').datepicker({
//comment the beforeShow handler if you want to see the ugly overlay
beforeShow: function() {
setTimeout(function(){
$('.ui-datepicker').css('z-index', 99999999999999);
}, 0);
}
});
// 패턴
let str = `
010-1234-5678
thesecon@gmail.com;
https://www.omdbapi.com/?apikey=7035c60c&s=frozen
The quick brown fox jumps over the lazy dog.
abbcccdddd
http
d`
console.log(
// d로 끝나는 부분을 찾는다.
str.match(/d$/gm)
)
console.log(
// t로 시작하는 부분을 찾는다.
str.match(/^t/gm)
)
console.log(
// h로 시작하고 p로 끝나는 문자를 찾는다 4자리
str.match(/h..p/g)
)
console.log(
// fox 또는 dog라는 값을 반환
str.match(/fox|dog/g)
)
console.log(
// s가 없거나 s가 있는 http로 시작하는 문자를 찾는다.
str.match(/https?/g)
)
// d가 2번 반복되는 곳을 찾는다.
console.log(
str.match(/d{2}/)
)
// d가 2번 이상 반복되는 곳을 찾는다.
console.log(
str.match(/d{2,}/)
)
// 2글자 이상 3글자 이하인 단어 검색
// 숫자나 알파벳이 아닌 것을 구분자로 선언
console.log(
str.match(/\b\w{2,3}\b/g)
)
// f 또는 o 또는 x 출력
console.log(
str.match(/[fox]/g)
)
// f 또는 o 또는 x 출력 연속 되는 문자 출력
console.log(
str.match(/[fox]{1,}/g)
)
// 0부터 9까지 연속되는 숫자 출력
console.log(
str.match(/[0-9]{1,}/g)
)
// 모든 문자 출력
console.log(
str.match(/\w/g)
)
// f로 시작하는 모든 영단어를 출력
console.log(
str.match(/\bf\w{1,}\b/g)
)
// 연속된 숫자 모두 출력
console.log(
str.match(/\d{1,}/g)
)
// 공백 문자 출력
console.log(
str.match(/\s/g)
)
// 공백문자 활용
const h = ` the hello world !
`
// 공백문자 제거
console.log(
h.replace(/\s/g, '')
)
// @앞쪽 일치 출력
console.log(
str.match(/.{1,}(?=@)/g)
)
// @ 뒤쪽 일치 출력
console.log(
str.match(/(?<=@).{1,}/g)
)
문자열.replace(정규식, 대체문자): 일치하는 문자열을 대체하고 대체된 문자열(String) 반환
예제
const str = `
010-1234-5678
hello@gmail.com;
https://www.omdbapi.com/?apikey=7035c60c&s=frozen
The quick brown fox jumps over the lazy dog.
abbcccdddd
`
// test(): boolean 값으로 반환
const regexp = /fox/gi
console.log(regexp.test(str))
// replace 문자 대체
console.log(str.replace(regexp, 'AAA'))