2012-04-26 3 views
1

데이터베이스로 채워진 표가 있습니다. 열 중 하나는 다른 테이블의 2 열의 concat입니다. 이 경우 팀의 위치와 이름입니다. 그러나 편집을 클릭하고 편집 양식이 채워지면 데이터베이스의 실제 팀과 비교하여 항상 드롭 다운에서 첫 번째 팀을 선택합니다. 여기 JqGrid 편집 양식이 드롭 다운에 적절한 항목을 표시하지 않습니다.

는 관련 코드의 일부입니다 :

jQuery("#listPlayer").jqGrid({ 
    url:'../controller/playerGrid.php', 
    datatype: "json", 
    colNames:['ID','First Name','Last Name', 'Team'], 
    colModel:[ 
      {name:'id',   index:'id',   width:20, editable:false, hidden:true}, 
      {name:'first_name', index:'first_name', width:80, editable:true, editrules: {required: true}}, 
      {name:'last_name', index:'last_name', width:80, editable:true, editrules: {required: true}}, 
      {name:'idTeam',  index:'idTeam',  width:50, editable:true, editrules: {required: true}, edittype: 'select', editoptions: { dataUrl: "../controller/listTable.php?query=team" } } 
    ], 
    rowNum:50, 
    rowTotal: 2000, 
    rowList : [20,30,50], 
    mtype: "POST", 
    rownumbers: true, 
    rownumWidth: 40, 
    gridview: true, 
    pager: '#pagerPlayer', 
    sortname: 'last_name', 
    viewrecords: true, 
    sortorder: "asc", 
    caption: "Player Manager", 
    editurl: "../controller/playerEditGrid.php" 

그리고이 같은 listTable.php에서 SQL 쿼리 모습입니다 : 나는 문제가 있다는 사실에있다 알고

SELECT t.id, CONCAT(t.location, ' ', t.name,' (', l.abbr, ')') as idTeam FROM team t, league l WHERE t.idLeague = l.id ORDER BY t.location 

단일 열에 반대되는 연결이지만 주위에 방법이 있다고 확신합니다 ... 나는 단지 그것을 알지 못합니다.

답변

1
나는이 방법을 사용하지 않은 있지만,있는 jqGrid 도움의 다음 부분은 당신의 사건에 적용해야

: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:common_rules#select

당신의 dataurl의 반환은 이미이어야한다 유효한 HTML select 요소와 같은 :

<select> 
<option value='1'>One</option> 
<option value='2'>Two</option> 
... 
</select> 

참조 3. 위 URL에 editoptions dataUrl 매개 변수을 설정하십시오.

희망이 도움이됩니다.

+0

예 이미 dataUrl을 사용하고 있으며 적절한 드롭 다운을 생성 할 수 있습니다. 제가 직면하고있는 문제는 편집 폼에 있습니다. 내 표에 표시되는 내용이 드롭 다운 목록과 다르므로 편집을 클릭하면 플레이어가 속한 팀을 기억하지 못합니다. – Falantar014

+0

@ Falantar014 : 그리드 소스 url이 dataurl에서 diff이므로 그리드의 * idTeam * 값이 편집 폼의 select : option 값과 다르다고 추측합니다. 이 경우 [buildselect] (http://www.trirand.com/jqgridwiki/doku.php?id=wiki%3acommon_rules#editoptions) 옵션을 사용하여 select : text 옵션의 텍스트 친숙한 텍스트이고 그 값은 그리드의 값과 일치합니다. 이 [답변] (http://stackoverflow.com/questions/4101116/asp-net-mvc-post-call-returning-string-need-help-with-format-for-jqgrid/4102155#4102155) 도움이 될 수 있습니다. out로 * buildselect * – justcurious

관련 문제