Table | CRUD - create, read, update, and delete

mod_harbour is an Apache module that allows to run PRGs directly on the web !!!
Post Reply
User avatar
Otto
Posts: 6419
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 43 times
Been thanked: 3 times
Contact:

Table | CRUD - create, read, update, and delete

Post by Otto »

Bootstrap-Table | CRUD - create, read, update, and delete

https://mybergland.com/fwforum/crud%20dbf.pdf

Image

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
Posts: 6419
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 43 times
Been thanked: 3 times
Contact:

Re: Table | CRUD - create, read, update, and delete

Post by Otto »

Hello friends,
everything works fine and the source code is easy to understand and clear.

I think switching to bootstrap-table was a good step.

I now do the updates for CRUD in 2 steps:

1. I send the request with Ajax and update the DBF file and

Code: Select all | Expand

function main()    local hPairs := AP_Body()    local hdata := {=>}     local hPost    local nRecNo := 0    cLog := ValToChar( hPairs ) + CRLF     MEMOWRIT("c:\www\htdocs\ajaxTableCRUD_DBF\log.log" , cLog, .f. )     hb_jsondecode( AP_Body(), @hPost )        cLog += valtype( hPost ) + CRLF    cLog += hPost["id"] + CRLF    cLog += hPost["name"]  + CRLF    cLog += hPost["kategorie"]  + CRLF        cLog += hPost["request"]  + CRLF    MEMOWRIT("c:\www\htdocs\ajaxTableCRUD_DBF\log.log" , cLog, .f. )     USE ( hb_GetEnv( "PRGPATH" )  + "/data/mylinks.dbf"  ) ALIAS "data" SHARED    if hPost["request"] = "append"        APPEND BLANK        nRecNo := recno()    else                GOTO VAL( hPost["id"] )     endif        if hPost["request"] = "delete"        dbRLock()        dbDelete()        dbUnlock()           cLog += "delete" + CRLF        cLog += str(recno())        MEMOWRIT("c:\www\htdocs\ajaxTableCRUD_DBF\log.log" , cLog, .f. )     else            dbRLock()        field->descript := ( rtrim(  hPost["name"] ) )        field->text := ( rtrim( hPost["kategorie"] ) )        dbUnlock()      endif        hdata['array'] := {}    GO TOP    do while !eof()        hItem := {=>}           hItem['id'] := VAL( hPost["id"] )         hItem['name'] := ( rtrim(  hPost["name"] ) )        hItem['kategorie'] := ( rtrim( hPost["kategorie"] ) )                aadd( hData['array'], hItem )                dbskip()    enddo        hData["recno"] := nRecNo    hData['success'] := 'true'        CLOSE         AP_SetContentType( "application/json" )        ?? hb_jsonEncode( hdata, .T. )  // T=pretty return NIL 


2. I use the Bootstrap function to update the table in the browser.

Code: Select all | Expand

$table.bootstrapTable('append', row );***$table.bootstrapTable('updateRow', {    index: first,    row: {        name:   putData["name"],        kategorie:  $("#kategorieEditInput").val()    }})***$table.bootstrapTable('remove', {    field: 'id',    values: cIdx}) 


How do you do that or how is it done in TWeb?
Best regards,
Otto


Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
Posts: 6419
Joined: Fri Oct 07, 2005 7:07 pm
Has thanked: 43 times
Been thanked: 3 times
Contact:

Re: Table | CRUD - create, read, update, and delete

Post by Otto »

Hello friend,
You can test the sample here:

https://www.modharbour.club/ajaxtablecrud_dbf/crud_dbf.prg

Here you can download the source code.
https://www.modharbour.club/ajaxtablecrud_dbf/ajaxTableCRUD_DBF.zip

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
Post Reply