Solved

Javascript error in DBNETGRID

Posted on 2013-02-01
14
655 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
Comment Utility
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
Comment Utility
No, this should work as is.  I verified this from multiple websites.
0
 
LVL 29

Expert Comment

by:fibo
Comment Utility
I presume you have checked that the value of accessString when initializing is correct and as expected?
0
 

Author Comment

by:devbackoffice
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
This is a native method of DBNetGrid API
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 29

Expert Comment

by:fibo
Comment Utility
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
Comment Utility
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
Comment Utility
Sorry to insist: have you checked that you have data to display?
0
 

Accepted Solution

by:
devbackoffice earned 0 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for your sugestions.  I will now close the question.
0
 

Author Closing Comment

by:devbackoffice
Comment Utility
Solution provided for version DBNetGrid 2.9
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now