Link to home
Start Free TrialLog in
Avatar of devbackoffice
devbackofficeFlag for United States of America

asked on

Javascript error in DBNETGRID

Hi,

I am not able to create a nested DBNetGrid due to javascript error.  Please see the code below:

function initialise(accessString)
{

setGridLooks(document.all.dbnetgrid1,accessString)
with (document.all.dbnetgrid1)
	{	
		fromPart = "[v_reporting_markit_cds_grouped]"
		orderColumn = "M_Z_DATE2"
		selectPart = ["ROLLUP_KEY", "M_Z_DATE2", "M_NB", "M_Z_SOURCEID", "M_Z_TRDNAME", "M_Z_TRDGRP", "M_CNT_USG", "M_TP_PFOLIO", "TransactionFlag", "UnderlyingTransactionFlag", "OriginalCounterpart", "FirstPaymentDate", "TradeDate", "EffectiveDate", "ScheduleTermDate", "UnderlyingScheduleTermDate", "M_TP_DSCTYPE", "M_INSTRUMENT", "RefObligation", "ReferenceEntityID", "M_Z_NOM1", "FixedRatePerAnnum", "M_Z_MV2", "M_Z_MV2_USD", "IntermediationBroker", "IntermediationBrokerCode", "M_Z_SPTCVPL", "M_Z_NOM1CUR", "M_DERIV_ACCRUED", "CleanMarketValue", "CleanMarketValueUSD", "CMA_ID", "Seniority", "M_Z_DATE2_RAW", "security_id", "MarkitRating", "M_TP_LENTDSP", "AlternativeSecRef", "USDIAAmount", "M_CCP", "M_USI", "TradeCount"];
		headings = ["ROLLUP_KEY", "M_Z_DATE2", "M_NB", "M_Z_SOURCEID", "M_Z_TRDNAME", "M_Z_TRDGRP", "M_CNT_USG", "M_TP_PFOLIO", "TransactionFlag", "UnderlyingTransactionFlag", "OriginalCounterpart", "FirstPaymentDate", "TradeDate", "EffectiveDate", "ScheduleTermDate", "UnderlyingScheduleTermDate", "M_TP_DSCTYPE", "M_INSTRUMENT", "RefObligation", "ReferenceEntityID", "M_Z_NOM1", "FixedRatePerAnnum", "M_Z_MV2", "M_Z_MV2_USD", "IntermediationBroker", "IntermediationBrokerCode", "M_Z_SPTCVPL", "M_Z_NOM1CUR", "M_DERIV_ACCRUED", "CleanMarketValue", "CleanMarketValueUSD", "CMA_ID", "Seniority", "M_Z_DATE2_RAW", "security_id", "MarkitRating", "M_TP_LENTDSP", "AlternativeSecRef", "USDIAAmount", "M_CCP", "M_USI", "TradeCount"];
		searchFields = ["M_Z_DATE2", "M_INSTRUMENT", "M_Z_TRDGRP", "M_CNT_USG", "M_CCP"];
		searchLabels = ["M_Z_DATE2", "M_INSTRUMENT", "M_Z_TRDGRP", "M_CNT_USG", "M_CCP"];
		
		/////////////////////////////////////////////////
		// set no text wrapping for all cells
		for (var i=0;i<selectPart.length;i++)
			setColumnProperty(selectPart[i],"noWrap:true");
		
		setColumnProperty("ROLLUP_KEY", "display", false)
		primaryKeyColumn = "ROLLUP_KEY"
		addNestedGrid(configureChildCDs, 'ROLLUP_KEY')
    }	
}

function configureChildCDs(parentGrid){
	with (parentGrid.childGrid)
	{	

		fromPart = "[v_reporting_markit_cds_details]"
		headings = ["ROLLUP_KEY", "ROLLUP_M_USI", "M_Z_DATE2", "M_NB", "M_Z_SOURCEID", "M_Z_TRDNAME", "M_Z_TRDGRP", "M_CNT_USG", "M_TP_PFOLIO", "TransactionFlag", "UnderlyingTransactionFlag", "OriginalCounterpart", "FirstPaymentDate", "TradeDate", "EffectiveDate", "ScheduleTermDate", "UnderlyingScheduleTermDate", "M_TP_DSCTYPE", "M_INSTRUMENT", "RefObligation", "ReferenceEntityID", "M_Z_NOM1", "FixedRatePerAnnum", "M_Z_MV2", "M_Z_MV2_USD", "IntermediationBroker", "IntermediationBrokerCode", "M_Z_SPTCVPL", "M_Z_NOM1CUR", "M_DERIV_ACCRUED", "CleanMarketValue", "CleanMarketValueUSD", "CMA_ID", "Seniority", "M_Z_DATE2_RAW", "security_id", "MarkitRating", "M_TP_LENTDSP", "AlternativeSecRef", "USDIAAmount", "M_CCP", "M_USI",];
		selectPart = ["ROLLUP_KEY", "ROLLUP_M_USI", "M_Z_DATE2", "M_NB", "M_Z_SOURCEID", "M_Z_TRDNAME", "M_Z_TRDGRP", "M_CNT_USG", "M_TP_PFOLIO", "TransactionFlag", "UnderlyingTransactionFlag", "OriginalCounterpart", "FirstPaymentDate", "TradeDate", "EffectiveDate", "ScheduleTermDate", "UnderlyingScheduleTermDate", "M_TP_DSCTYPE", "M_INSTRUMENT", "RefObligation", "ReferenceEntityID", "M_Z_NOM1", "FixedRatePerAnnum", "M_Z_MV2", "M_Z_MV2_USD", "IntermediationBroker", "IntermediationBrokerCode", "M_Z_SPTCVPL", "M_Z_NOM1CUR", "M_DERIV_ACCRUED", "CleanMarketValue", "CleanMarketValueUSD", "CMA_ID", "Seniority", "M_Z_DATE2_RAW", "security_id", "MarkitRating", "M_TP_LENTDSP", "AlternativeSecRef", "USDIAAmount", "M_CCP", "M_USI",];
		displayToolbar = false	
		
		/////////////////////////////////////////////////
		// set no text wrapping for all cells
		for (var i=0;i<selectPart.length;i++)
			setColumnProperty(selectPart[i],"noWrap:true");
		//loadData()
	}
}

Open in new window


The parent results show fine, but the child function does not work.  When I click on "+" sign in the parent grid, I get a javascript error

Object Required
Line 27 - which is where I have
 with (parentGrid.childGrid)

Open in new window

specified.  If I change that to just be parentGrid, I don't get a javascript error when I click on a plus but it does not return me any data for the nested grid.
Avatar of Bernard Savonet
Bernard Savonet
Flag of France image

Seems the ParentGrid has no child.
1 - You might test for presence of childhood before "with-ing" it
2 -I don't know dbNetGrid. Is it supposed to define childhood? The code listed here does not seem to do
Avatar of devbackoffice

ASKER

No, this should work as is.  I verified this from multiple websites.
I presume you have checked that the value of accessString when initializing is correct and as expected?
I verified and it is defined. I changed the code as follows:

function configureChildCDs(parentGrid){
	with (parentGrid.childGrid)
	{	
		DBMSName = "Microsoft SQL Server"
		connectionString = "MurexDwSqlDev.MurexProd_DevOpen"
		fromPart = "[v_reporting_markit_cds_details]"
		headings = ["ROLLUP_KEY", "ROLLUP_M_USI", "M_Z_DATE2", "M_NB", "M_Z_SOURCEID", "M_Z_TRDNAME", "M_Z_TRDGRP", "M_CNT_USG", "M_TP_PFOLIO", "TransactionFlag", "UnderlyingTransactionFlag", "OriginalCounterpart", "FirstPaymentDate", "TradeDate", "EffectiveDate", "ScheduleTermDate", "UnderlyingScheduleTermDate", "M_TP_DSCTYPE", "M_INSTRUMENT", "RefObligation", "ReferenceEntityID", "M_Z_NOM1", "FixedRatePerAnnum", "M_Z_MV2", "M_Z_MV2_USD", "IntermediationBroker", "IntermediationBrokerCode", "M_Z_SPTCVPL", "M_Z_NOM1CUR", "M_DERIV_ACCRUED", "CleanMarketValue", "CleanMarketValueUSD", "CMA_ID", "Seniority", "M_Z_DATE2_RAW", "security_id", "MarkitRating", "M_TP_LENTDSP", "AlternativeSecRef", "USDIAAmount", "M_CCP", "M_USI",];
		selectPart = ["ROLLUP_KEY", "ROLLUP_M_USI", "M_Z_DATE2", "M_NB", "M_Z_SOURCEID", "M_Z_TRDNAME", "M_Z_TRDGRP", "M_CNT_USG", "M_TP_PFOLIO", "TransactionFlag", "UnderlyingTransactionFlag", "OriginalCounterpart", "FirstPaymentDate", "TradeDate", "EffectiveDate", "ScheduleTermDate", "UnderlyingScheduleTermDate", "M_TP_DSCTYPE", "M_INSTRUMENT", "RefObligation", "ReferenceEntityID", "M_Z_NOM1", "FixedRatePerAnnum", "M_Z_MV2", "M_Z_MV2_USD", "IntermediationBroker", "IntermediationBrokerCode", "M_Z_SPTCVPL", "M_Z_NOM1CUR", "M_DERIV_ACCRUED", "CleanMarketValue", "CleanMarketValueUSD", "CMA_ID", "Seniority", "M_Z_DATE2_RAW", "security_id", "MarkitRating", "M_TP_LENTDSP", "AlternativeSecRef", "USDIAAmount", "M_CCP", "M_USI",];
		displayToolbar = false	
		
		/////////////////////////////////////////////////
		// set no text wrapping for all cells
		for (var i=0;i<selectPart.length;i++)
			setColumnProperty(selectPart[i],"noWrap:true");
		//loadData()
	}

Open in new window

I don't know if this helps, but I call the js from aspx page.  Here is how the last revision of the code looks like. I got rid of anything extra.

function initialise()
{
	with (dbnetgrid1)
	{	
		headings = ["ROLLUP KEY", "DATE"];
		selectPart = ["ROLLUP_KEY", "M_Z_DATE2"];
		fromPart = "[v_reporting_markit_cds_grouped]"
		primaryKeyColumn = "ROLLUP_KEY"
		connectionString = "MurexDwSqlDev.MurexProd_DevOpen"
		
		addNestedGrid(configureChildCDs, "ROLLUP_KEY")
		loadData()
    }	
}

function configureChildCDs( parentGrid )
{
	if (parentGrid.childGrid == null)
	{	
		alert("Child grid is not defined")
		return
	}
	with (parentGrid.childGrid)
	{	
		displayToolbar = false	
		fromPart = "[v_reporting_markit_cds_details]"
		headings = ["ROLLUP KEY", "DATE", "ID"];
		selectPart = ["ROLLUP_KEY", "M_Z_DATE2", "M_NB"];
		loadData()
	}
}

Open in new window


I always get "Child grid is not defined" alert that I set up.  Child seems to always be null for some reason.
I presume the data for addNestedGrid comes from some sql query that you have defined before addNestedGrfid.

What happens if the query returns no data?
This is a native method of DBNetGrid API
1 - From what I read at page http://www.dbnetsuite.net/samples/DbNetGrid/NestedGrids.aspx I would bet that in your initial example it should be
function configureChildCDs(parentGrid){
	with (parentGrid)

Open in new window


2 - You say that in that case you get no value.
This might have 2 causes:
- your data query returns values but there is an error somewhere and nothing displays
- your data query returns no value and you have no error

Hence my previous question: are you sure your query returns records? Have you any way to run the query directly and check the result
(Afterthought: you have data in the base, right?)
I tried this example where I replaced parentGrid.ChildGrid with just grid.  Now I don't get the error message but it seems that the retrieval never happens for the nested grid. I clicked on + but no results were displayed.  I also noticed that when I  do
displayToolbar = false

Open in new window

it is being ignored and I still see the toolbar.
Sorry to insist: have you checked that you have data to display?
ASKER CERTIFIED SOLUTION
Avatar of devbackoffice
devbackoffice
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
B-) You should now close the question, allocating points to yourself since you provided the solution.
(Do not delete / cancel the question, so that it and its answer stay in the database)
Thanks for your sugestions.  I will now close the question.
Solution provided for version DBNetGrid 2.9