Hi.

I was using the version 5.x of Ajax and works fine (except by the array
as parameter).
In order to load a dropdownlist with a datatable i use the following
code (from 5.x), but this does not work on 6.x version (and the options
of use DataRow are not visible):

 -- The problem: dataTable.value.Rows is undefined, and DataRow is
unknown --

Is posible found examples like in the 5.x version in order to check
what's the matter and upgrade my code.

esanchezfo.js.LoadDropDownListFromDataTable = function
(
        dropdownlist, dataTable_table, fieldName_text,
        fieldName_value, selectedValue, doSelectIfOnlyOne, disableIfOnlyOne,
        fieldName_extraValue, fieldName_leftMark, fieldName_rigthMark,
bool_appendExtraValue,
        elementId_textIfOnlyOne
)
{
        var option;


        if (esanchezfo.js.FilterAjaxError (dataTable_table.error)) { return; }

        esanchezfo.js.ClearDropDownList (dropdownlist);

        if
        (
                dataTable_table == null || dataTable_table.value == null ||
                dataTable_table.value == 0 || dataTable_table.value.Rows.length 
== 0
        )
        {
                if (dropdownlist.size == 0)
                {
                        option = document.createElement ('OPTION');
                        option.text = '- No hay -'
                        option.value = '';

                        dropdownlist.options.add (option, 0);
                }

                return false;
        }


        for (var i = 0; i < dataTable_table.value.Rows.length; i++)
        {
                option = document.createElement ('OPTION');

                option.text =  dataTable_table.value.Rows [i][fieldName_text];
                option.value = dataTable_table.value.Rows [i][fieldName_value];

                if (typeof (fieldName_extraValue) != "undefined")
                {
                        if (fieldName_leftMark != "undefined") { option.text +=
fieldName_leftMark; }
                        else { option.text += " ("; }

                        option.text += dataTable_table.value.Rows 
[i][fieldName_extraValue];

                        if (fieldName_rigthMark != "undefined") { option.text +=
fieldName_rigthMark; }
                        else { option.text += ")"; }

                        if (bool_appendExtraValue) { option.value += "|" +
dataTable_table.value.Rows [i][fieldName_extraValue]; }
                }

                dropdownlist.options.add (option, i);
        }

        if (dropdownlist.size <= 0)
        {
                option = document.createElement ('OPTION');
                option.text = '- Seleccione uno -'
                option.selected = true;
                option.value = '';

                dropdownlist.options.add (option, 0);
        }

        if (elementId_textIfOnlyOne != null && typeof
(elementId_textIfOnlyOne) != "undefined")
        {
                if (dataTable_table.value.Rows.length == 1)
                {
                        esanchezfo.js.SetInnerHTMLFromText 
(elementId_textIfOnlyOne,
dataTable_table.value.Rows [0][fieldName_text]);
                        esanchezfo.js.HideElementById (dropdownlist.id);
                }
        }

        if (dataTable_table.value.Rows.length == 1)
        {
                if (doSelectIfOnlyOne) { dropdownlist.selectedIndex =
(dropdownlist.size > 0 ? 0 : 1); }

                if (disableIfOnlyOne)
                {
                        dropdownlist.selectedIndex = (dropdownlist.size > 0 ? 0 
: 1);
                        esanchezfo.js.DisableElementById (dropdownlist.id);
                }

                return true;
        }

        if (selectedValue != null) { return
esanchezfo.js.SelectByValueDropDownList (dropdownlist, selectedValue);
}
        
        return true;
}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Ajax.NET Professional" group.

To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]

For more options, visit this group at http://groups.google.com/group/ajaxpro

The latest downloads of Ajax.NET Professional can be found at 
http://www.ajaxpro.info
-~----------~----~----~----~------~----~------~--~---

Reply via email to