Skip to content

Infragistics Community Forum / Web / Ultimate UI for ASP.NET Web Forms / WebDataGrid error "Should be a function, function name, or function text"

WebDataGrid error "Should be a function, function name, or function text"

New Discussion
Stephen
Stephen asked on Dec 20, 2011 10:09 PM

I have a webdatagrid in ASP.NET page using Infragistics  Version=10.3.20103.2120 and .NET 2.0.

The client side function is below:

function wdgEmployeeDeductions_RowSelectionChanged()
{
var grid = getGrid();
var behav = grid.get_behaviors();
var selection = behav.get_selection();

var selectedRow = selection.get_selectedRows();
var row = selectedRow.getItem(0) ;

var lbldeduction = $get(‘<%#lbldeduction.ClientID%>’);
var lblrateamount = $get(‘<%#lblrateamount.ClientID%>’);
var lblfrequency = $get(‘<%#lblfrequency.ClientID%>’);
var lblgoal = $get(‘<%#lblgoal.ClientID%>’);
var lblpaid = $get(‘<%#lblpaid.ClientID%>’);
var lblminimum = $get(‘<%#lblminimum.ClientID%>’);
var lblmaximum = $get(‘<%#lblmaximum.ClientID%>’);
var lbllasttaken = $get(‘<%#lbllasttaken.ClientID%>’);
var lblytdmax = $get(‘<%#lblytdmax.ClientID%>’);
var lblstartdate = $get(‘<%#lblstartdate.ClientID%>’);
var lblenddate = $get(‘<%#lblenddate.ClientID%>’);
var lblnotes = $get(‘<%#lblnotes.ClientID%>’);
var lblcc1 = $get(‘<%#lblcc1.ClientID%>’);
var lblcc2 = $get(‘<%#lblcc2.ClientID%>’);
var lblcc3 = $get(‘<%#lblcc3.ClientID%>’);
var lblcc4 = $get(‘<%#lblcc4.ClientID%>’);
var lblcc5 = $get(‘<%#lblcc5.ClientID%>’);
var lbljobcode = $get(‘<%#lbljobcode.ClientID%>’);

var cell = row.get_cell(16) ;
var value = cell.get_Value();
If (value != null)
{
document.getElementById(‘lbldeduction’).innerHTML=value;
}
Else
{
document.getElementById(‘lbldeduction’).innerHTML=””;
}

var cell = row.get_cell(18) ;
var value = cell.get_Value();
If (value != null)
{
document.getElementById(‘lblrateamount’).innerHTML=value;
}
Else
{
document.getElementById(‘lblrateamount’).innerHTML=””;
}
var value = selectedRow.GetItem(0).get_Cell(6).get_Value();
If (value != null)
{
document.getElementById(‘lblfrequency’).innerHTML=value;
}
Else
{
document.getElementById(‘lblfrequency’).innerHTML=””;
}
var value = selectedRow.GetItem(0).get_Cell(7).get_Value();
If (value != null)
{
document.getElementById(‘lblgoal’).innerHTML=value;
}
Else
{
document.getElementById(‘lblgoal’).innerHTML=””;
}
var value = selectedRow.GetItem(0).get_Cell(8).get_Value();
If (value != null)
{
document.getElementById(‘lblpaid’).innerHTML=value;
}
Else
{
document.getElementById(‘lblpaid’).innerHTML=””;
}
var value = selectedRow.GetItem(0).get_Cell(9).get_Value();
If (value != null)
{
document.getElementById(lblminimum’).innerHTML=value;
}
Else
{
document.getElementById(‘lblminimum’).innerHTML=””;
}
var value = selectedRow.GetItem(0).get_Cell(10).get_Value();
If (value != null)
{
document.getElementById(‘lblmaximum’).innerHTML=value;
}
Else
{
document.getElementById(‘lblmaximum’).innerHTML=””;
}
var value = selectedRow.GetItem(0).get_Cell(11).get_Value();
If (value != null)
{
ddd= new Date(value);
var value=(ddd.getMonth()+1 + “/” + ddd.getDate() + “/” + ddd.getFullYear());
document.getElementById(‘lbllasttaken’).innerHTML=value;
}
Else
{
document.getElementById(‘lbllasttaken’).innerHTML=””;
}
var value = selectedRow.GetItem(0).get_Cell(12).get_Value();
If (value != null)
{
document.getElementById(‘lblytdmax’).innerHTML=value;
}
Else
{
document.getElementById(‘lblytdmax’).innerHTML=””;
}
var value = selectedRow.GetItem(0).get_Cell(13).get_Value();
If (value != null)
{
ddd = new date(value);
var value=((ddd.getMonth()+1) + “/” + ddd.getDate() + “/” + ddd.getFullYear());
document.getElementById(‘lblstartdate’).innerHTML=value;
}
Else
{
document.getElementById(‘lblstartdate’).innerHTML=””;
}
var value = selectedRow.GetItem(0).get_Cell(14).get_Value();
If (value != null)
{
ddd = new date(value);
var value=((ddd.getMonth()+1) + “/” + ddd.getDate() + “/” + ddd.getFullYear());
document.getElementById(‘lblenddate’).innerHTML=value;
}
Else
{
document.getElementById(‘lblenddate’).innerHTML=””;
}
var value = selectedRow.GetItem(0).get_Cell(15).get_Value();
If (value != null)
{
document.getElementById(‘lblnotes’).innerHTML=value;
}
Else
{
document.getElementById(‘lblnotes’).innerHTML=””;
}
var value = selectedRow.GetItem(0).get_Cell(16).get_Value();
If (value != null)
{
document.getElementById(‘lblcc1’).innerHTML=value;
}
Else
{
document.getElementById(‘lblcc1’).innerHTML=””;
}
var value = selectedRow.GetItem(0).get_Cell(17).get_Value();
If (value != null)
{
document.getElementById(‘lblcc2’).innerHTML=value;
}
Else
{
document.getElementById(‘lblcc2’).innerHTML=””;
}
var value = selectedRow.GetItem(0).get_Cell(18).get_Value();
If (value != null)
{
document.getElementById(‘lblcc3’).innerHTML=value;
}
Else
{
document.getElementById(‘lblcc3’).innerHTML=””;
}
var value = selectedRow.GetItem(0).get_Cell(19).get_Value();
If (value != null)
{
document.getElementById(‘lblcc4’).innerHTML=value;
}
Else
{
document.getElementById(‘lblcc4’).innerHTML=””;
}
var value = selectedRow.GetItem(0).get_Cell(20).get_Value();
If (value != null)
{
document.getElementById(‘lblcc5’).innerHTML=value;
}
Else
{
document.getElementById(‘lblcc5’).innerHTML=””;
}
var value = selectedRow.GetItem(0).get_Cell(21).get_Value();
If (value != null)
{
document.getElementById(‘lbljobcode’).innerHTML=value;
}
Else
{
document.getElementById(‘lbljobcode’).innerHTML=””;
}
}
</script>

 

At one point this was partially working and I was debugging the rest, but then it started throwing this exception again.

 

Here is page_load of the code behind:

Page.Header.DataBind()
If Not Page.IsPostBack Then
Active_Row = 0
Setup_Grid()
Fill_Grid()
Setup_Screen()
End If

Fill_Grid() gets a dataset from SQL server database and then calls a procedure BindControls() which binds the dataset to the wdg_EmployeeDeductions.datasource.

Row selectors are enabled.

CellSelectionAction is set to “Row”. CellSelectionType is set to “None”.  RowSelectType is set to single. RowSelectionChanged is set to wdgEmployeeDeductions_RowSelectionChanged which is the name of the function being called.

Any assistance is appreciated.

Sign In to post a reply

Replies

  • 0
    Alex E
    Alex E answered on Nov 29, 2011 9:49 AM

    Hello ssjostrom,

    Thank you for posting on Infragistics forum.

    If you have placed the function in the page “<head>” element and inside the “<script>” tag and specified the name of the function correctly in the grid “Client Events”, then you should try to add “sender” and “eventArgs” parameters in the function and test this again:

    function <function name>(sender, eventArgs){}

    If this does not resolve the exception you can try to use the Visual Studio designer to create the function body and see if this behavior will be present again.

    Inform me if this information is helpful in your scenario.

    • 0
      Stephen
      Stephen answered on Nov 29, 2011 1:40 PM

      Hello Alex,

      I tried adding the sender and eventArgs to the function:

      function wdgEmployeeDeductions_RowSelectionChanged(wdgEmployeeDeductions, eventArgs)
          {…}

      The function is inside a  <script type="text/javascript" id="igClientScript2">  </script> set.  The getGrid() function is inside its own set of tags.  Both are in the <head id="Head1" runat="server"> section.

      I have tried it with one set of script tags also.

      The ASP for the webdatagrid behaviors is below:

       <ig:WebDataGrid ID="wdgEmployeeDeductions" runat="server" CssClass="GridBorderStyle"
                                Height="104px" Width="778px" AutoGenerateColumns="False">
                                <Behaviors>
                                    <ig:RowSelectors>
                                    </ig:RowSelectors>
                                    <ig:Selection CellClickAction="Row" CellSelectType="None" RowSelectType="Single">
                                        <SelectionClientEvents RowSelectionChanged="wdgEmployeeDeductions_RowSelectionChanged" />
                                    </ig:Selection>
                                </Behaviors>

      The error occurs as the grid on the page is loading. When you clear the error, the page completes loading and clicking on a row in the grid does nothing.  Right now I am just trying to get it working in IE 8.0.7601.17514.

      We are using VS2005, not 2010.

      I have viewed the videos and gone through the forums looking for resolutions and have yet to find one.

      Thanking you in advance for your continued assistance.

  • 0
    Alex E
    Alex E answered on Nov 29, 2011 3:23 PM

    Hello ssjostrom,

    What you can do first is to create a new empty project and add a grid on it. You can then enable selection behavior for this grid and add the “RowSelectionChanged” client event trough Visual Studio 2005 designer (grid behaviors dialog from the Smart Tag – Add New Handler).

    Then you should run this project and see if the exception will be present again.

    If it is not, you should continue to add parts of your code and rerun the page until you get the same error message.

    This is one of the possible ways to determine which part of the code is actually causing this exception.

    Try this approach and inform me what the results are.

    • 0
      Stephen
      Stephen answered on Nov 29, 2011 8:21 PM

      Thank you Alex.

      I tried that by commenting out sections of code until the error went away.  Now I have another error "Error: Object doesn't support this property or method" on line 57.  I have a suspicion as to what it might be but IE's debugger is locking up on me today.  I'll have an our help desk look at it.

      In the meantime, here is the code I am left with:

      function wdgEmployeeDeductions_RowSelectionChanged(wdgEmployeeDeductions, eventArgs)
          {
          var grid = getGrid();
          var behav = grid.get_behaviors();
          var selection = behav.get_selection();
          ///<summary>
          ///
          ///</summary>
          ///<param name="sender" type="Infragistics.Web.UI.WebDataGrid"></param>
          ///<param name="eventArgs" type="Infragistics.Web.UI.RowSelectionChangedEventArgs"></param>
             
          //Add code to handle your event here.
          var selectedRow = selection.get_selectedRows();
          var row = selectedRow.getItem(0) ;
         
             var lbldeduction = $get('<%#lbldeduction.ClientID%>');
          var lblrateamount = $get('<%#lblrateamount.ClientID%>');
          var lblfrequency = $get('<%#lblfrequency.ClientID%>');
          var lblgoal = $get('<%#lblgoal.ClientID%>');
          var lblpaid = $get('<%#lblpaid.ClientID%>');
          var lblminimum = $get('<%#lblminimum.ClientID%>');
          var lblmaximum = $get('<%#lblmaximum.ClientID%>');
          var lbllasttaken = $get('<%#lbllasttaken.ClientID%>');
          var lblytdmax = $get('<%#lblytdmax.ClientID%>');
          var lblstartdate = $get('<%#lblstartdate.ClientID%>');
          var lblenddate = $get('<%#lblenddate.ClientID%>');
          var lblnotes = $get('<%#lblnotes.ClientID%>');
          var lblcc1 = $get('<%#lblcc1.ClientID%>');
          var lblcc2 = $get('<%#lblcc2.ClientID%>');
          var lblcc3 = $get('<%#lblcc3.ClientID%>');
          var lblcc4 = $get('<%#lblcc4.ClientID%>');
          var lblcc5 = $get('<%#lblcc5.ClientID%>');
          var lbljobcode = $get('<%#lbljobcode.ClientID%>');
         
             
          var cell = row.get_cell(16) ;
          var value = cell.get_Value();
          if (value != null)
          {
              document.getElementById('lbldeduction').innerHTML=value;
          }
          else
          {
              document.getElementById('lbldeduction').innerHTML="";
          }

      My suspicion is that cell.get_Value() is not valid, although I am not sure why that is.

      Any ideas?

      • 0
        Alex E
        Alex E answered on Nov 30, 2011 1:48 PM

        Hello ssjostrom,

        Normally the function for getting value of the cell is written in without capital letters:

        cell.get_value();

        Since the JavaScript is case sensitive language this can lead to the exception shown

        You can put breakpoint before calling of this function and actually see the functions available for the cell object.

        I hope that this will help in your situation.

      • 0
        Stephen
        Stephen answered on Dec 2, 2011 3:34 PM

        Alex,

        This has helped.  I am starting to make some progress with this.

        Thanks,

      • 0
        Alex E
        Alex E answered on Dec 5, 2011 8:41 AM

        Hello ssjostrom,

        Inform me if you need additional assistance with this question.

      • 0
        Stephen
        Stephen answered on Dec 20, 2011 10:09 PM

        I just wanted to let you know that I now have the grid working.  Thanks for the help!

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Stephen
Favorites
0
Replies
8
Created On
Dec 20, 2011
Last Post
14 years, 2 months ago

Suggested Discussions

Created by

Created on

Dec 20, 2011 10:09 PM

Last activity on

Feb 19, 2026 9:36 PM