I have a query web part set up within a wiki that I'm using to do a pretty simple search of our allele database. The qwp is rendered when the user fills out a form and clicks a submit button. I have a similar form on the same page that is set up to insert the values from the form into a new entry within the table holding the allele information. When I make a new entry I can see it if I directly navigate to the table to view the data, but not when I render the qwp. The other thing is if I use LabKey's built in insert function and click cancel the new entries will load if I submit the form completely blank. That is until I navigate away and return to the page. Please find my javascript below:
Inserting the data into the new table
function subInsert(data) {
var uidValue = data.rows[0].maxId + 1;
console.log(myValues2);
//console.log(maxId);
//var uidValue = maxId.rows[0].maxId + 1;
console.log(uidValue);
var userId = LABKEY.Security.currentUser.displayName;
var d = new Date();
var date = d.getDate();
var year = d.getFullYear();
var month = d.getMonth() + 1;
LABKEY.Query.insertRows({
schemaName: 'oconnor',
queryName: 'dna_sequences_draft_2013',
rows: [
{'allele_name': myValues2['alleleName'],
'region': myValues2['region'],
'file_active': 1,
'locus': myValues2['locus'],
'allele_family': myValues2['alleleFamily'],
'species': myValues2['species'],
'origin': myValues2['origin'],
'genbank_id': myValues2['genbankId'],
'ipd_accession': myValues2['ipdAccession'],
'previous_name': myValues2['previousName'],
'last_edit': year + "-" + month + "-" + date,
'initials': userId,
'sequence': myValues2['sequence'],
'modified_by': userId,
'type': myValues2['type'],
'uid': uidValue,
'id': uidValue,
'comments': myValues2['comments'],
'variant': 1,
'reference': 1,
'full_length': myValues2['fullLength']
}],
successCallback: function() {Ext.MessageBox.alert('Insert Allele', 'Successfully inserted ' + myValues2['alleleName']);},
});
}
creating the qwp
var qwp1 = new LABKEY.QueryWebPart({
renderTo: 'queryTestDiv1',
title: 'Search Results',
schemaName: 'oconnor',
queryName: 'dna_sequences_draft_2013',
containerFilter: 'currentAndSubfolders',
filters: [LABKEY.Filter.create('species', myValues['species'], LABKEY.Filter.Types.CONTAINS), LABKEY.Filter.create('file_active', '1', LABKEY.Filter.Types.EQUAL), LABKEY.Filter.create('allele_name', myValues['alleleName'], LABKEY.Filter.Types.CONTAINS), LABKEY.Filter.create('region', myValues['region'], LABKEY.Filter.Types.CONTAINS), LABKEY.Filter.create('locus', myValues['locus'], LABKEY.Filter.Types.CONTAINS), LABKEY.Filter.create('origin', myValues['origin'], LABKEY.Filter.Types.CONTAINS), LABKEY.Filter.create('type', myValues['type'], LABKEY.Filter.Types.CONTAINS), LABKEY.Filter.create('allele_family', myValues['alleleFamily'], LABKEY.Filter.Types.CONTAINS), LABKEY.Filter.create('comments', myValues['comments'], LABKEY.Filter.Types.CONTAINS), LABKEY.Filter.create('modified_by', myValues['modifiedBy'], LABKEY.Filter.Types.CONTAINS), LABKEY.Filter.create('previous_name', myValues['previousName'], LABKEY.Filter.Types.CONTAINS), LABKEY.Filter.create('genbank_id', myValues['genbankId'], LABKEY.Filter.Types.CONTAINS), LABKEY.Filter.create('ipd_accession', myValues['ipdAccession'], LABKEY.Filter.Types.CONTAINS)],
showUpdateColumn: true,
maxRows: myValues['rb-auto'],
buttonBar: {
includeStandardButtons: false,
items:[
//LABKEY.QueryWebPart.standardButtons.insertNew,
LABKEY.QueryWebPart.standardButtons.deleteRows,
LABKEY.QueryWebPart.standardButtons.exportRows
]
}
}); |