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

mod_harbour is an Apache module that allows to run PRGs directly on the web !!!

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

Postby Otto » Sun Dec 20, 2020 9:32 pm

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: 6329
Joined: Fri Oct 07, 2005 7:07 pm

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

Postby Otto » Wed Dec 23, 2020 4:05 pm

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 view

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 view

$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: 6329
Joined: Fri Oct 07, 2005 7:07 pm

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

Postby Otto » Mon Mar 01, 2021 9:25 pm

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
********************************************************************
User avatar
Otto
 
Posts: 6329
Joined: Fri Oct 07, 2005 7:07 pm


Return to mod_harbour

Who is online

Users browsing this forum: No registered users and 4 guests