CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Error 500 when adding a new record on a subgrid

by RobertoLopes » 05 Apr 2016 21:16

Hello

I have a grid with another grid as subgrid . The tables used by Grid and subgrid are bellow (MySQL)

On the main grid:

CaseID (int)
OpenDate (TDateTime)
Status (int)
Priority(int)

On the subgrid

CaseId (int)
OperatorId(int)
ChangeDate(TDateTime)
CaseDescription (Longtext)


the problem is that the CaseID, OperatorId and ChangeDate are NOT Editable . Only the description is.

How can I place a Default Value on the fields that are not Editable ?

I'm getting the Error 500 (filed 'id' cannot be null).

NOTE: The column Id is NOT visible on the subgrid.

Please Help me
RobertoLopes
 
Posts: 15
Joined: 07 Mar 2016 21:09

by assapan » 06 Apr 2016 07:46

Hi,
you can have default value directly in MySql schema or use the OnNewRecord event of Table/Query or OnAdd event of DataSetProvider
Want to visit Ardeche http://leclosdelarc.fr/index.php
The Pont d’Arc Cavern http://en.cavernedupontdarc.fr
Image
User avatar
assapan
 
Posts: 600
Joined: 16 Dec 2013 12:04
Location: France

by RobertoLopes » 06 Apr 2016 13:14

I Cannot use Default value on MySQL database since the keys must be inherited from the main record.
I'll try the events you mentioned and post the feedback soon.

Thanks a lot.
RobertoLopes
 
Posts: 15
Joined: 07 Mar 2016 21:09

by RobertoLopes » 08 Apr 2016 13:43

Thanks man That works perfectly.

Now i'm facing another problem. I have a column called "Status" on my table that is an ID. On the grid column I put the description of this status based on a "Status" table. (Lookup)

The edittype property on this column is Select but the value that must go to the table is the ID of that status.

On the OnNewRecord event, how can I pick the chosen Status to convert it to my ID and place on the dataset ?
RobertoLopes
 
Posts: 15
Joined: 07 Mar 2016 21:09

by assapan » 08 Apr 2016 18:52

Have a look to CGDevtools demo , in getSelectData event you have to fill the Adata with value and displa string.

Code: Select all
procedure TFrameGrid.GridGetSelectData(Sender: TObject; ACol: TIWCGJQGridCol; AData: TStrings);
begin
  AData.Values['']:= 'Select';
  AData.Values['1']:= 'One';
  AData.Values['2']:= 'Two';
  AData.Values['3']:= 'Three';
end;
Want to visit Ardeche http://leclosdelarc.fr/index.php
The Pont d’Arc Cavern http://en.cavernedupontdarc.fr
Image
User avatar
assapan
 
Posts: 600
Joined: 16 Dec 2013 12:04
Location: France

by RobertoLopes » 08 Apr 2016 20:45

Right

I already do that. Displaying is not the problem. Adding a new record is. On adding a new record, O must present the description values on the combo but the actual value to be inserted on the database is an ID (numeric).

How can I do that ?
RobertoLopes
 
Posts: 15
Joined: 07 Mar 2016 21:09

by Alexander Bulei » 11 Apr 2016 14:09

Hi,

Please check the source of our demo JQueryDemoV3_IW14.
Search for tblInvoiceLinesNewRecord.

Best Regards.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal


Return to JQGrid

cron

Who is online

Users browsing this forum: No registered users and 17 guests

Contact Us.