私はこの exampleに基づいてフィルタツールバーを作成しました。私には奇妙な問題があります。これはFirebugブレークポイントが設定されている場合にのみ動作し、そうでない場合はドロップダウンに「All」と表示されます。グリッドはデータ型 'json'、loadonce:trueで設定されます。もう一つのポイント。このグリッドにはサブグリッドもあります。どのようにこれを動作させるための任意のアイデア?うJqgrid検索ツールバーは、Jsonで一意のドロップリストをフィルタリングします
colModel:[
{name:'CM',index:'CM', width:50,editable:false},
{name:'DealNo',index:'DealNo',width:75,editable:false,editoptions:{readonly:true, size:10},search:true, stype:'text', searchoptions: { sopt: ['eq']}},
{name:'KeyDate',index:'KeyDate',width:100, search:false, align:"right",formatter:'date'},
{name:'VendorNo',index:'VendorNo', width:75,search:true},
{name:'VendorName',index:'VendorName', width:100,search:true},
{name:'ItemQty',index:'ItemQty', width:75,search:false},{name:'StartDate',index:'StartDate',width:100,align:"right",formatter:'date',search:false},
{name:'EndDate',index:'EndDate',width:100, align:"right",formatter:'date',search:false},
{name:'ActiveStartDate',index:'ActiveStartDate',width:100, align:"right",formatter:'date',search:false, sorttype:"date", editable:true,editoptions:{size:10}}, {name:'ActiveEndDate',index:'ActiveEndDate',width:100,align:"right",formatter:'date',search:false, sorttype:"date",editable:true,editoptions:{size:10}},
{name:'DealType',index:'DealType', width:75,search:false}
],
そして最後に、私の呼び出しは任意の提案をfilterToolBarを作成して、ドロップダウン
setSearchSelect('CM');
grid.jqGrid('setColProp', 'Name', {
searchoptions : {
sopt : [ 'cn' ],
dataInit : function(elem) {
$(elem).autocomplete({
source : getUniqueNames('Name'),
delay : 0,
minLength : 0
});
}
}
});
grid.jqGrid('filterToolbar', {
stringResult : true,
searchOnEnter : true,
defaultSearch : "eq"
});
を移入するために:私は、グリッドを宣言した後、私のコラムモデルは次のようになります
grid = $("#dealsgrid"),
getUniqueNames = function(columnName) {
var texts = grid.jqGrid('getCol', columnName);
var uniqueTexts = [];
var textsLength = grid.jqGrid('getGridParam','data');
var text, textsMap = {}, i;
for (i = 0; i < textsLength; i++) {
text = texts[i];
if (text !== undefined && textsMap[text] === undefined) {
// to test whether the texts is unique we place it in the map.
textsMap[text] = true;
uniqueTexts.push(text);
}
}
return uniqueTexts;
},
buildSearchSelect = function(uniqueNames) {
var values = ":All";
$.each(uniqueNames, function() {
values += ";" + this + ":" + this;
});
return values;
},
setSearchSelect = function(columnName) {
grid.jqGrid(
'setColProp',
columnName,
{
stype : 'select',
searchoptions : {
value : buildSearchSelect(getUniqueNames(columnName)),
sopt : [ 'eq' ]
}
});
};
大変感謝します。 ありがとう
jsfiddleで問題を再現してください。どうぞご覧ください。私はすでにあなたのために適切なリソース(cssとjs)を含むものを作成しました - http://jsfiddle.net/yTX3P/1/それを忘れずに保存してください。 –
@Martijn B私のコードは、[link](http://jsfiddle.net/yTX3P/4/embedded/result/) – Heather
から入手できます。あなたの例では問題は再現されません。利用可能なデータはありません。私はあなたにこのようにお手伝いできません。あなたが試みることができるのは、getUniqueNamesメソッドからreturn uniqueTextsにブレークポイントを置き、返される値を確認することです。これが空の場合は、getUniqueNamesメソッドに焦点を当てる必要があります。 –