6
Vote

JS error in SelectorField

description

Hi,
 
I've placed SelectorField into my GridView to have a RadioButton column there.
<mb:SelectorField SelectionMode="Single" AutoPostBack="false" />
When my page loads IE reports a JS error:
Line: 5
Char: 19
Error: 'MetaBuilders_SelectorField_CheckAllBoxes' is undefined
Code: 0
URL: (mine)
 
How to fix it ?
I looked into the JS file, it seems like this variable/array was not defined anywhere...
 
Thanks,
 
Slava

comments

jack33 wrote Feb 27, 2008 at 12:26 AM

Same error. I used the SelectorField in a GridView which sits inside a usercontrol. Always shows the js error 'MetaBuilders_SelectorField_CheckAllBoxes' is undefined'.

Anyone got any ideas? Thanks

DarthRob wrote Jun 22, 2008 at 8:45 PM

For me, this error occurs when the GridView that contains the SelectorField is not Visible. In this case, MetaBuilders_SelectorField_CheckAllBoxes is undeclared. To test for an undeclared JavaScript variable, you could use typeof(). In "SelectorFieldScript.js" change the first function so that it looks like this:

function MetaBuilders_SelectorField_Init() {
if ( typeof( document.getElementById ) == "undefined" ) return;
window.MetaBuilders_SelectorField_Fields = new Object();
if (typeof(MetaBuilders_SelectorField_CheckAllBoxes) != "undefined") {
    for( var i=0; i < MetaBuilders_SelectorField_CheckAllBoxes.length; i++ ) {
        var info = MetaBuilders_SelectorField_CheckAllBoxes[i];
        var checkAllBox = document.getElementById( info.ID );
        checkAllBox.participants = new Array(); 
        MetaBuilders_SelectorField_Fields[ info.Field ] = checkAllBox;

        for( var j=0; j < MetaBuilders_SelectorField_CheckBoxes.length; j++ ) {
            var selectorInfo = MetaBuilders_SelectorField_CheckBoxes[j];
            if ( selectorInfo.Field == info.Field ) {
                checkAllBox.participants[ checkAllBox.participants.length ] = document.getElementById( selectorInfo.ID );
            }
        }
    }
}
}

wrote Jun 22, 2008 at 8:46 PM

PianoMan wrote Mar 17, 2009 at 8:03 PM

I just downloaded v0.9.4, converted the old RowSelector to SelectorField, converted my DataGrid to a GridView, ran my code and immediately encountered the error 'MetaBuilders_SelectorField_CheckAllBoxes' is undefined'.

Any chance someone could fix this?

wrote Mar 17, 2009 at 8:04 PM

PianoMan wrote Mar 17, 2009 at 8:08 PM

Also: According to the documentation CheckAllBox(es) is used when SelectionMode = Multiple. I've set SelectionMode = Single.

Is there a workaround? Perhaps I can setup an empty CheckAllBox object and the JS code will function w/o error?
There's no example in the documentation so I don't know how to set up an CheclAllBox object.

eriso wrote Mar 18, 2009 at 9:47 AM

I'm having the same issuse. Selectorfield in GridView in a usercontrol.

wrote Mar 18, 2009 at 9:47 AM

ciceroferreira wrote May 26, 2009 at 8:05 PM

Hi guys...

I found the same problem and i fix it when i put the follow block of code.
<script type="text/javascript"> //<![CDATA[ var MetaBuilders_SelectorField_CheckAllBoxes = new Array({ Field:'ctl00_ContentPlaceHolder1_GridView1_SelectorField1', ID:'ctl00_ContentPlaceHolder1_GridView1_ctl01_ctl00' }); var MetaBuilders_SelectorField_CheckBoxes = new Array({ Field:'ctl00_ContentPlaceHolder1_GridView1_SelectorField1', ID:'ctl00_ContentPlaceHolder1_GridView1_ctl02_ctl01' }, { Field:'ctl00_ContentPlaceHolder1_GridView1_SelectorField1', ID:'ctl00_ContentPlaceHolder1_GridView1_ctl03_ctl01' }, { Field:'ctl00_ContentPlaceHolder1_GridView1_SelectorField1', ID:'ctl00_ContentPlaceHolder1_GridView1_ctl04_ctl01' }); //]]> </script>

mpadierna wrote Mar 29, 2010 at 7:26 PM

Solved!
You need to download the source of MetaBuilders.WebControls,
open it in VS,
then edit the file "SelectorFieldScript.js", as DarthRob pointed out
then rebuild and you're done!

alasaadi wrote Nov 11, 2010 at 5:56 AM

Hi guys,

I am having the same problem here, did any one manage to get it working,
can any one attach the generated dll file after changing the first function in "SelectorFieldScript.js" as DarthRob pointed out.

wrote Feb 14, 2013 at 2:25 AM

wrote May 21, 2013 at 1:20 AM