我在jqxgrid中使用我的xml数据加载到网格中,我想找到重复的值并从网格的第一列中删除:
我在警报中找到了重复的值,任何人都可以帮忙解决这个问题吗?
我的HTML:
<div id="jqxgridAccountUpdates" class="jqx-hideborder jqGrid"> </div>
XML:
<Accounts>
<Account>
<Company>Company 1</Company>
<AccountNo>12345</AccountNo>
<CCY>EUR</CCY>
<Link>Link</Link>
<StatusIMG>Approved</StatusIMG>
</Account>
<Account>
<Company>Company 1</Company>
<AccountNo>12345</AccountNo>
<CCY>EUR</CCY>
<Link>Link</Link>
<StatusIMG>Approved</StatusIMG>
</Account>
<Account>
<Company>Company 1</Company>
<AccountNo>12345</AccountNo>
<CCY>EUR</CCY>
<Link>Link</Link>
<StatusIMG>Approved</StatusIMG>
</Account>
<Account>
<Company>Company 1</Company>
<AccountNo>12345</AccountNo>
<CCY>EUR</CCY>
<Link>Link</Link>
<StatusIMG>Approved</StatusIMG>
</Account>
<Account>
<Company>Company 2</Company>
<AccountNo>12345</AccountNo>
<CCY>EUR</CCY>
<Link>Link</Link>
<StatusIMG>Approved</StatusIMG>
</Account>
<Account>
<Company>Company 2</Company>
<AccountNo>12345</AccountNo>
<CCY>EUR</CCY>
<Link>Link</Link>
<StatusIMG>Approved</StatusIMG>
</Account>
<Account>
<Company>Company 2</Company>
<AccountNo>12345</AccountNo>
<CCY>EUR</CCY>
<Link>Link</Link>
<StatusIMG>Approved</StatusIMG>
</Account>
<Accounts>
JS(在我的准备功能中):
var LatestAccounturl = "scripts/jqwidgets/sampledata/latestAccountUpdates.xml";
var LatestAccountsource =
{
datatype: "xml",
mtype: 'GET',
datafields: [
{ name: 'Company', type: 'String'},
{ name: 'AccountNo', type: 'int' },
{ name: 'CCY', type: 'String' },
{ name: 'Link', type: 'bool' },
{ name: 'StatusIMG', type: 'String' }
],
root: "Accounts",
record: "Account",
url: LatestAccounturl
};
var LatestAccountdataAdapter = new $.jqx.dataAdapter(LatestAccountsource, {
loadComplete: function (data) {
var xml = $(data);
var compArray = [];
$('Accounts > Account > Company', xml).each(function() {
//alert($(this).text());
var compTxt = $(this).text();
if(compArray.indexOf(compTxt) > -1){
alert("DUPLICATE: " + compTxt);
} else {
compArray.push(compTxt);
}
});
},
loadError: function (xhr, status, error) { alert("nooo"); }
});