Solved

Javascript error in DBNETGRID

Posted on 2013-02-01
14
667 Views
Last Modified: 2013-02-11
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.
0
Comment
Question by:devbackoffice
  • 8
  • 6
14 Comments
 
LVL 29

Expert Comment

by:fibo
ID: 38846247
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
0
 

Author Comment

by:devbackoffice
ID: 38851259
No, this should work as is.  I verified this from multiple websites.
0
 
LVL 29

Expert Comment

by:fibo
ID: 38851589
I presume you have checked that the value of accessString when initializing is correct and as expected?
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:devbackoffice
ID: 38851646
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

0
 

Author Comment

by:devbackoffice
ID: 38855668
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.
0
 
LVL 29

Expert Comment

by:fibo
ID: 38856215
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?
0
 

Author Comment

by:devbackoffice
ID: 38856376
This is a native method of DBNetGrid API
0
 
LVL 29

Expert Comment

by:fibo
ID: 38856777
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?)
0
 

Author Comment

by:devbackoffice
ID: 38856959
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.
0
 
LVL 29

Expert Comment

by:fibo
ID: 38858428
Sorry to insist: have you checked that you have data to display?
0
 

Accepted Solution

by:
devbackoffice earned 0 total points
ID: 38859798
Figured it out with my coworker's help. The version I am using is older version of DBNetGrid and needs to use different type of reference:

with (window.event.srcElement.childGrid)

Open in new window

0
 
LVL 29

Expert Comment

by:fibo
ID: 38859833
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)
0
 

Author Comment

by:devbackoffice
ID: 38859837
Thanks for your sugestions.  I will now close the question.
0
 

Author Closing Comment

by:devbackoffice
ID: 38875419
Solution provided for version DBNetGrid 2.9
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question