Bootstrap-Table | CRUD - create, read, update, and delete
https://mybergland.com/fwforum/crud%20dbf.pdf
Best regards,
Otto
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
$table.bootstrapTable('append', row );
***
$table.bootstrapTable('updateRow', {
index: first,
row: {
name: putData["name"],
kategorie: $("#kategorieEditInput").val()
}
})
***
$table.bootstrapTable('remove', {
field: 'id',
values: cIdx
})
Users browsing this forum: No registered users and 7 guests