A Simple Editable Grid in COM API ASP

Hints, Tips and Tricks

Technical Hints Tips and Tricks that cover customization and development using Sage CRM. API usage and coding are covered.

A Simple Editable Grid in COM API ASP

  • Comments 7
  • Likes
This article covers the creation of an editable grid. By this I mean the presentation of data in a spreadsheet like structure, each row in the grid a separate record and each column a separate field.

The code sample below is very simple and should only be considered a rough outline of how such a grid can be developed. But I hope this may be useful.

<!-- #include file ="sagecrm.js"-->
var myRecordId = CRM.GetContextInfo('user','user_userid');
if (String(Request.Form("comp_companyid"))!='undefined')
myEditRecord = CRM.FindRecord('company','comp_companyid='+Request.Form("comp_companyid"));
myEditRecord.comp_name = Request.Form("comp_name");
//<!--Retrieve Record -->
var myRecord = CRM.FindRecord('company','comp_primaryuserid='+myRecordId);
//<!-- Setup Block Container -->
var myBlockContainer = CRM.GetBlock('container');
var ContentBlock = CRM.GetBlock('content');
myBlockContainer.DisplayButton(Button_Default) = false;
myBlockContainer.DisplayForm = false;
//<!--Record Use Example -->
myRecord.OrderBy = 'comp_companyid' //ASC and DESC can be used.
ContentBlock.contents = "<table width='100%'><tr><td class=gridhead>Company Name</td></tr>";
var rowflag = 1
var rowclass
while (!myRecord.eof) //eof checks for end of data and instantiates query
if (rowflag == 1)
rowclass = "row1";
rowflag = 2;
rowclass = "row2";
rowflag = 1;
ContentBlock.contents += '<tr><td class='+rowclass+' valign=bottom><form method=post name='+myRecord.comp_companyid +'><input type="hidden" name="comp_companyid" value="'+myRecord.comp_companyid+'"> <input type="text" class="Edit" onchange=submit() name="comp_name" value="'+myRecord.comp_name+'"></form></td></tr>';
//<!--Add Entry Block -->
ContentBlock.contents += "</table>";
  • Hi Jeff,

    I amended your code and got an error object expected when the on change takes place. Page dispys correct. I could not find my error.  I used your code as it is and got the same error and does not want to update the record in the list.

    What am I doing wrong? This is exactly what I want to do on my asp page but I am not able to get it working.


  • David

    I thought you were on honeymoon? - But I have corrected the code above.  This works it you add the page into the User system menu (the My CRM menu).

  • Hi Jeff,

    Can we add a new record in a grid shown above ?

    I want to know about ajax and Jquery....can we implement ajax to enter a new record in a grid and are saved in a database without refreshing a page ?

  • Yusuf

    You could certainly use Ajax to extend the behaviour of this type of screen.  But you would also then have to refresh the screen to refresh the list.  The whole page would need to be redesigned.  Much easier to create a custom gadget within the company Interactive Dashboard that allowed the rapid entry of opportunities which would then be listed in another List gadget.

  • Hi All,

    Can this code be used with a SQL view instead of a table?


  • Try using

    CRM.FindRecord('company, vsummarycompany','comp_companyid='+Request.Form("comp_companyid"));

  • Thank you.... perfect!