Results as an array

May 25, 2010 at 12:50 AM
Edited May 25, 2010 at 12:52 AM

Hello,

I was wondering if you could help me with an issue I’m having with flexbox. I’ve been at this for 5 hours and you’re really my last hope before I switch to another method.

I’m working in ASP.net and trying to build the “results” for the flex box dynamically with a JSON object. I am returning an object that is basically an array. Each item in the array is an object with name value pairs. Two of which are “id” and “name”. I’m trying to find a way to loop through the objects in my array, but FB doesn’t seem to accept an array?

I have been able to get the text only version of the “JSON example” running. My real issue is when I try to use an array of objects.

If it helps I’m using flexbox 0.9.2.2 and jquery 1.2.6

function SetLegalEntityKey_cb(obj) {
$('#fb_counterparty').flexbox({
                "results": [
                    for(var i=0,len=obj.Properties.results.length; i<len; i++) {
                           "obj.Properties.results[i];
                    },
                ], "total": obj.Message
                },
                {
                    allowInput: false,
                    watermark: ' --please select Counterparty to load addresses--',
                    paging: false,
                    maxVisibleRows: 60,
                    width: 299,
                    paging: { pageSize: 60 },
                    arrowQuery: ''
                });
}
 

Thank you very much for your time

Coordinator
May 25, 2010 at 4:17 AM

It looks you are trying to populate the array on the fly with a for loop, which I think would only work if you used an “eval” statement.  Also, it looks like you’re missing a quote (or have an extra quote) near obj.Properties.results[i].  My recommendation is to generate the JSON on the server side, if possible.  I have a demonstration project in the CodePlex source code that you can download to see one (very simple) way to generate the JSON manually.

Good luck… and sorry it’s taken so long.  I know how frustrating that can be.

Noah

From: dev1t [mailto:notifications@codeplex.com]
Sent: Monday, May 24, 2010 5:50 PM
To: Noah Heldman
Subject: Results as an array [flexbox:213706]

From: dev1t

Hello, I was wondering if you could help me with an issue I’m having with flexbox. I’ve been at this for 5 hours and you’re really my last hope before I switch to another method. I’m working in ASP.net and trying to build the “results” for the flex box dynamically with a JSON object. I am returning an object that is basically an array. Each item in the array is an object with name value pairs. Two of which are “id” and “name”. I’m trying to find a way to loop through the objects in my array, but FB doesn’t seem to accept an array? I have been able to get the text only version of the “JSON example” running. My real issue is when I try to use an array of objects. If it helps I’m using flexbox 0.9.2.2 and jquery 1.2.6 function SetLegalEntityKey_cb(obj) { $('#fb_counterparty').flexbox({ "results": [ for(var i=0,len=obj.Properties.results.length; i<len; i++) { "obj.Properties.results[i]; }, ], "total": obj.Message }, { allowInput: false, watermark: ' --please select Counterparty to load addresses--', paging: false, maxVisibleRows: 60, width: 299, paging: { pageSize: 60 }, arrowQuery: '' }); }

Read the full discussion online.

To add a post to this discussion, reply to this email (flexbox@discussions.codeplex.com)

To start a new discussion for this project, email flexbox@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

May 25, 2010 at 12:20 PM

Well, I actually gave it an other hour and I got it. It turned out to be my syntax when passing the array of objects.  I was actually returning the array of objects from the server already (sorry for not mentioning that) so it was really just making it fit that was the issue. Here is the code I used to get the array in there.

The key is that after "results": you have to drop the [ ] and replace it with the array name.  As long as each of your objects has properties for id and name you're good to go. I also ended up addding the resultsTemplate parameter to the flexbox call as well as a "DisplayAddress" property to each object in my array.

$('#fb_counterparty').flexbox({
                "results": obj.Properties.results
                    , "total": obj.Message
                },
                {
                    width: 299, resultTemplate: '<span title="{DisplayAddress}" style="float:left">{name}</div>',
                    maxVisibleRows: 60, paging: { pageSize: 10 },
                    paging: true,
                    watermark: ' --please select Counterparty to load addresses--',
                    initialValue: $('#ctl01_uxMainContent_uxACP_Wizard_hidCounterpartyAddress_AddressDisplay_Initial').val(),
                    arrowQuery: '',
                    allowInput: true,
                    onSelect: function() {
                        $('#ctl01_uxMainContent_uxACP_Wizard_hidCounterpartyAddress_AddressID').val(this.getAttribute('hiddenValue'));
                        $('#txtCounterpartyResultValue').val(this.getAttribute('hiddenValue'));
                        $('#txtCounterpartyResultName').val(this.getAttribute('name'));
                    }             
                });
I hope this helps someone out at some point.
Ray
Coordinator
May 25, 2010 at 6:27 PM

Thanks for posting your solution… glad you figured it out!

Noah

From: dev1t [mailto:notifications@codeplex.com]
Sent: Tuesday, May 25, 2010 5:20 AM
To: Noah Heldman
Subject: Re: Results as an array [flexbox:213706]

From: dev1t

Well, I actually gave it an other hour and I got it. It turned out to be my syntax when passing the array of objects. I was actually returning the array of objects from the server already (sorry for not mentioning that) so it was really just making it fit that was the issue. Here is the code I used to get the array in there.

The key is that after "results": you have to drop the [ ] and replace it with the array name. As long as each of your objects has properties for id and name you're good to go. I also ended up addding the resultsTemplate parameter to the flexbox call as well as a "DisplayAddress" property to each object in my array.

$('#fb_counterparty').flexbox({
                "results": obj.Properties.results
                    , "total": obj.Message
                },
                {
                    width: 299, resultTemplate: '{name}
',

                    maxVisibleRows: 60, paging: { pageSize: 10 },
                    paging: true,
                    watermark: ' --please select Counterparty to load addresses--',
                    initialValue: $('#ctl01_uxMainContent_uxACP_Wizard_hidCounterpartyAddress_AddressDisplay_Initial').val(),
                    arrowQuery: '',
                    allowInput: true,
                    onSelect: function() {
                        $('#ctl01_uxMainContent_uxACP_Wizard_hidCounterpartyAddress_AddressID').val(this.getAttribute('hiddenValue'));
                        $('#txtCounterpartyResultValue').val(this.getAttribute('hiddenValue'));
                        $('#txtCounterpartyResultName').val(this.getAttribute('name'));
                    }             
                });
I hope this helps someone out at some point.
Ray

Read the full discussion online.

To add a post to this discussion, reply to this email (flexbox@discussions.codeplex.com)

To start a new discussion for this project, email flexbox@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com