2012-11-21 2 views
1

편집/추가 양식에서 jqGrid 한 필드는 파일을 업로드해야합니다. 처음에는 edittype = file을 사용합니다. 나는이 기능을 텍스트 필드에 표시해야합니다 선택 사용자jqgrid 파일에 대한 편집 유형 사용자 정의

function myelem (value, options) { 
             var el=$("<div class='type_file'>"+ 
             "<input type='file' class='inputFile' id='"+options.name+"' name='"+options.name+"'/>" + 
             "<div class='fonTypeFile'><input type='text' class='inputFileVal' readonly='readonly' id='fileName'"+ 
             " /></div>"+ 
             "</div>"); 
             var g='',val_file; 
             $('.inputFile').change(function() { 
              g=$('.inputFile').val();  alert(g);         
              $('.inputFileVal').val(g);            
             }); 

            return el; 
            } 
            function myvalue(elem, operation, value) { 
             $('input',elem).val(''); 
            } 

파일을 통해 edittype = 사용자 정의를 사용하는 이유하지만이 요소의보기를 변경해야합니다, 그건. 그러나 그것은 효과가 없습니다. 어떻게 바꿀 수 있니?

답변

0

양식에 요소를 추가 한 다음 사용자 정의 요소의 오프셋을 사용하여 이미지 (업로드)에 오프셋을 만듭니다.

CSS :

.customelement { 
position: absolute; 
top: 0; 
left: 0; 
z-index: 2; 
filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0); 
-moz-opacity: 0; 
-khtml-opacity: 0; 
opacity: 0; 
width: 237px; } 
.fonTypeFile { 
width: 237px; 
height: 23px; 
background: url(images/inputFile.png); 
position: relative; 
top: 0; 
left: 22; 
z-index: 1;}  

.inputFileVal { 
position: relative; 
top: 3px; 
left: 5px; 
z-index: 2; 
width: 150px; 
background: none; 
border: none;} 

스크립트

function myelem (value, options) { 
             var st="<input type='file'/><div class='fonTypeFile'><input type='text' class='inputFileVal' readonly='readonly' id='fileName'/></div>";            
             var el=$(st); 
              $(el).change(function() {              
                var val_f=$(el).val(); 
                $('.inputFileVal').val(val_f); 
              }); 
             return el; 
           } 
            function myvalue(elem, operation, value) { 
             return $(elem).find("input").val(); 
            } 
function for_file(){ 
             $(".fonTypeFile").removeClass("customelement"); 
             var form_offset=$('.FormGrid').offset(); 
             var offset=$('.fonTypeFile').offset(); 
             var left=offset.left-form_offset.left; 
             var top=offset.top-form_offset.top; 
             $('.customelement').css({'left':left, 'top':top}); 
            } 
$('#words').jqGrid({...}).navGrid('#wordsPager',... {...afterShowForm: function (formid) for_file(); }...}); 
관련 문제