如何使用<font-color = change>编辑datatable的列

时间:2019-04-25 05:23:13

标签: laravel

我无法在下面的编辑栏中找到创建字体颜色的方法。

这是我想做的例子

public function list(Request $request){
    $items = Item::get();

    $datatables = DataTables::of($items)
    ->editColumn('stock_qty', function($item){
      if($item->stock_qty <= $item->low_stock_threshold){
        return 'red font';
      } else {
        return 'black font';
      }
    })
    ->rawColumns(['stock_qty']);

    return $datatables->make(true);
  }

作为回报,我尝试更改一些代码,但给我空值。

如果stock_qty低显示红色字体,我是否可以比较该值。

->editColumn('stock_qty', function($item){
     ** if($item->stock_qty <= $item->low_stock_threshold){
        return '<font color="red> '+ $item->stock_qty +'</font>;
      } else {
        return $stock_qty;
      }
    })**
  1. 低库存时字体颜色变为红色,否则显示黑色。

  2. 请帮助我,谢谢。

2 个答案:

答案 0 :(得分:0)

PHP中的串联运算符是 self.x, self.y = 50, 50 def triangle(self): width = self.width.get() length = self.length.get() color = self.color_select.get() self.canvas.create_line(self.x, self.y, (self.x + (int(length) / 2)), (self.y + int(length)), fill = color) self.canvas.create_line(self.x, self.y, (self.x - (int(length) / 2)), (self.y + int(length)), fill = color) self.canvas.create_line((self.x - (int(length) / 2)), (self.y + int(length)), (self.x + (int(length) / 2)), (self.y + int(length)), fill = color) self.x += 50 def square(self): width = self.width.get() length = self.length.get() color = self.color_select.get() self.canvas.create_line(self.x, self.y, self.x + int(width), self.y, fill = color) self.canvas.create_line(self.x, self.y, self.x, self.y + int(length), fill = color) self.y += int(length) self.canvas.create_line(self.x, self.y, self.x + int(width), self.y, fill = color) self.x += int(width) self.canvas.create_line(self.x, self.y, self.x, self.y - int(length), fill = color) self.y -= int(length) self.x += 50 def pentagon(self): width = self.width.get() length = self.length.get() color = self.color_select.get() def hexagon(self): width = self.width.get() length = self.length.get() color = self.color_select.get() ,而不是 <endpoint xmlns="http://ws.apache.org/ns/synapse" name="Service"> <wsdl uri="https://yourServer/yourService?wsdl" service="yourService" port="yourServiceSoap"> <suspendOnFailure> <progressionFactor>1.0</progressionFactor> </suspendOnFailure> <markForSuspension> <retriesBeforeSuspension>0</retriesBeforeSuspension> <retryDelay>0</retryDelay> </markForSuspension> </wsdl> </endpoint> ,就像javascript中一样。

因此应为<service name="yourService"> <port name="yourServiceSoap" binding="yourServiceSoapBinding"> <soapbind:address location="https://yourServer/service/yourService.asmx"/> </port> </service>

答案 1 :(得分:0)

我认为,您错过了red之后的双引号:)

->editColumn('stock_qty', function($item){
 ** if($item->stock_qty <= $item->low_stock_threshold){
    return '<font color="red"> '+ $item->stock_qty +'</font>;
  } else {
    return $stock_qty;
  }
})**